Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Adding fields to HistoryPolicy

On Martes 13 Septiembre 2011 03:15:56 Pavel Arnost escribió:

> Hi,

>

> I would like to add "user" (from Spring Security context) and "timestamp"

> fields to history tables. From HistoryPolicy class source code, it looks

> like that there is not direct support for another fields, but logicalInsert

> and mappinglogicalInsert methods could be overriden and modified.

>

> What is the difference between logicalInsert and mappingLogicalInsert? Do

> you know any other approach than overriding logicalInsert and

> mappingLogicalInsert methods?

>

> Regards,

> Pavel Arnost

Hello.

I don't know if this is what you want. But I do this in my projects:

I use a Superclass to add auditUser and timestamp:

@MappedSuperclass

public class Model implements Serializable {

/**

* El usuario que realizó la última modificación.

*/

@Column

private String auditUser;

/**

* La fecha y hora de la última modificación.

*/

@Version

private Timestamp version;

...

@PrePersist

@PreUpdate

public void updateAuditInfo() {

setAuditUser(SecurityHelper.getCurrentUsername());

}

}

The SecurityHelper is a class that call spring security and give to me the current username.

Them , I implements the HistoryPolicy in the inhereted class of model.

I know is not the best option, but is the simplest one.


--

I.S.C. José Arcángel Salazar Delgado

Gerente de I+D

Tel. oficina: 229-9-27-54-78

Attachment: signature.asc
Description: This is a digitally signed message part.


Back to the top