ObjectDB ObjectDB

@PrePersist Implementation

#1

Hi Please help me.I have requirement like

In my project having arround 100 pojos .I have used @EntityListener and @prePersist annotaions to invoke my action class ..

But problem is how can i get oldvalue and new value of current form of pojo in side my @entity Listener Action class.

code snipt

=====

Action class

=======

public class AuditLogAction extends ActionSupport implements ModelDriven<IptAuditLog> {
//public class AuditLogAction extends ActionSupport implements AuditorWare<IptAuditLog>

@PrePersist
public void prePersist(Object obj) {
    System.out.println("=========@PrePersist Annotation is called on iptAuditLog id: Before Saving Record into the Entity MAnager.==========");
   }
}

Pojo

====


@Entity

@EntityListeners({AuditLogAction.class})

@Table(name = "IPT_AUDIT_LOG")
public class IptAuditLog implements  PKPersistence<Long> {
}

in action runtime any pojo will come then what kind of pojo values can i capture inside prePersist() method

edit
delete
#2

You will have to collect the information in a combination of more than one event.

When a managed entity object is updated, to get the entity before the update use the @PreUpdate event, and to get the entity after the update use @PostUpdate.

In order to be able to get told value in the @PreUpdate event, the entity class must be enhanced, otherwise the event is fired only after the change is applied.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
edit
delete

Reply

To post on this website please sign in.