KickJava   Java API By Example, From Geeks To Geeks.

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


1 //$Id: EJB3MergeEventListener.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.DefaultMergeEventListener;
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 EJB3MergeEventListener extends DefaultMergeEventListener {
14     private EntityCallbackHandler callbackHandler;
15
16     public EJB3MergeEventListener(EntityCallbackHandler callbackHandler) {
17         this(false, callbackHandler);
18     }
19
20     public EJB3MergeEventListener(boolean saveOrµUpdateCopy, EntityCallbackHandler callbackHandler) {
21         super(saveOrµUpdateCopy);
22         this.callbackHandler = callbackHandler;
23     }
24
25     @Override JavaDoc protected boolean invokeSaveLifecycle(Object JavaDoc entity, EntityPersister persister, EventSource source) {
26         callbackHandler.preCreate( entity ); //always call the precreate event even if on safe vetoe it
27
return super.invokeSaveLifecycle( entity, persister, source );
28
29     }
30 }
31
Popular Tags