public class HibernateEventListener extends Object implements org.hibernate.event.spi.SaveOrUpdateEventListener, org.hibernate.event.spi.PreUpdateEventListener
| Constructor and Description |
|---|
HibernateEventListener() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
onPreUpdate(org.hibernate.event.spi.PreUpdateEvent event)
Sets the modifiedBy and modifiedDate properties on objects that inherit from
BaseModel. |
void |
onSaveOrUpdate(org.hibernate.event.spi.SaveOrUpdateEvent event)
For new objects that are created, this event is used to set the audit properties.
|
public boolean onPreUpdate(org.hibernate.event.spi.PreUpdateEvent event)
BaseModel.
event.getState() is used to get the list of properties for the object as these are the properties that Hibernate generates
the UPDATE statement for. A separate session is used to get the User object to ensure that the object thus obtained is
flushed from within the event. @ return false to continue the processingonPreUpdate in interface org.hibernate.event.spi.PreUpdateEventListenerpublic void onSaveOrUpdate(org.hibernate.event.spi.SaveOrUpdateEvent event)
onSaveOrUpdate in interface org.hibernate.event.spi.SaveOrUpdateEventListenerCopyright © 2015–2017 eGovernments Foundation. All rights reserved.