KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > ejb > callback > EJB3SaveEventListener


1 //$Id: EJB3SaveEventListener.java,v 1.1 2005/07/21 00:08:33 epbernard Exp $
2
package org.hibernate.ejb.callback;
3
4 import org.hibernate.event.def.DefaultSaveEventListener;
5 import org.hibernate.event.EventSource;
6 import org.hibernate.persister.entity.EntityPersister;
7
8 /**
9  * Overrides the LifeCycle OnSave call to call the PrePersist operation
10  *
11  * @author Emmanuel Bernard
12  */

13 public class EJB3SaveEventListener extends DefaultSaveEventListener {
14     private EntityCallbackHandler callbackHandler;
15
16     public EJB3SaveEventListener(EntityCallbackHandler callbackHandler) {
17         super();
18         this.callbackHandler = callbackHandler;
19     }
20
21     @Override JavaDoc protected boolean invokeSaveLifecycle(Object JavaDoc entity, EntityPersister persister, EventSource source) {
22         callbackHandler.preCreate( entity ); //always call the precreate event even if on safe vetoe it
23
return super.invokeSaveLifecycle( entity, persister, source );
24     }
25 }
26
Popular Tags