HHH-7451 - Integrate Draft 7 of the JPA 2.1 spec : more ejb->jpa rename

This commit is contained in:
Steve Ebersole 2012-07-17 18:13:02 -05:00
parent 6a65c3e7e6
commit 06d44951c6
21 changed files with 357 additions and 416 deletions

View File

@ -1,72 +0,0 @@
/*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.ejb.connection;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
import javax.sql.DataSource;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Environment;
import org.hibernate.jpa.internal.EntityManagerMessageLogger;
import org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl;
/**
* A specialization of {@link DatasourceConnectionProviderImpl} which uses the {@link DataSource} specified vi
* {@link #setDataSource} rather than locating it from JNDI.
* <p/>
* NOTE : {@link #setDataSource} must be called prior to {@link #configure}.
* <p/>
* TODO : could not find where #setDataSource is actually called. Can't this just be passed in to #configure???
*
* @author Emmanuel Bernard
*/
public class InjectedDataSourceConnectionProvider extends DatasourceConnectionProviderImpl {
private static final EntityManagerMessageLogger LOG = Logger.getMessageLogger(EntityManagerMessageLogger.class,
InjectedDataSourceConnectionProvider.class.getName());
private String user;
private String pass;
@Override
public void setDataSource(DataSource ds) {
super.setDataSource( ds );
}
public void configure(Properties props) throws HibernateException {
user = props.getProperty( Environment.USER );
pass = props.getProperty( Environment.PASS );
if (getDataSource() == null) throw new HibernateException("No datasource provided");
LOG.usingProvidedDataSource();
}
@Override
public Connection getConnection() throws SQLException {
if (user != null || pass != null) return getDataSource().getConnection(user, pass);
return getDataSource().getConnection();
}
}

View File

@ -1,8 +1,10 @@
/* /*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as * Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2009-2012, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution * indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are * statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC. * distributed under license by Red Hat Inc.
* *
* This copyrighted material is made available to anyone wishing to use, modify, * This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU * copy, or redistribute it subject to the terms and conditions of the GNU
@ -22,23 +24,23 @@
package org.hibernate.engine.spi; package org.hibernate.engine.spi;
/** /**
* Becasue CascadeStyle is not opened and package protected, * Because CascadeStyle is not opened and package protected,
* I need to subclass and override the persist alias * I need to subclass and override the persist alias
* *
* Note that This class has to be triggered by EJB3PersistEventListener at class loading time * Note that This class has to be triggered by JpaPersistEventListener at class loading time
* *
* TODO get rid of it for 3.3 * TODO get rid of it for 3.3
* *
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
public abstract class EJB3CascadeStyle extends CascadeStyle { public abstract class JpaCascadeStyle extends CascadeStyle {
/** /**
* cascade using EJB3CascadingAction * cascade using JpaCascadingAction
*/ */
public static final CascadeStyle PERSIST_EJB3 = new CascadeStyle() { public static final CascadeStyle PERSIST_JPA = new CascadeStyle() {
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return action== EJB3CascadingAction.PERSIST_SKIPLAZY return action== JpaCascadingAction.PERSIST_SKIPLAZY
|| action==CascadingAction.PERSIST_ON_FLUSH; || action==CascadingAction.PERSIST_ON_FLUSH;
} }
public String toString() { public String toString() {
@ -47,6 +49,6 @@ public abstract class EJB3CascadeStyle extends CascadeStyle {
}; };
static { static {
STYLES.put( "persist", PERSIST_EJB3 ); STYLES.put( "persist", PERSIST_JPA );
} }
} }

View File

@ -27,7 +27,6 @@ import java.util.Map;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.jpa.internal.EntityManagerMessageLogger;
import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.EventSource;
import org.hibernate.type.CollectionType; import org.hibernate.type.CollectionType;
@ -37,10 +36,9 @@ import org.hibernate.type.CollectionType;
* TODO Get rid of it for 3.3 * TODO Get rid of it for 3.3
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
public abstract class EJB3CascadingAction extends CascadingAction { public abstract class JpaCascadingAction extends CascadingAction {
private static final Logger LOG = Logger.getLogger( JpaCascadingAction.class.getName() );
private static final EntityManagerMessageLogger LOG = Logger.getMessageLogger(EntityManagerMessageLogger.class,
EJB3CascadingAction.class.getName());
/** /**
* @see org.hibernate.Session#persist(Object) * @see org.hibernate.Session#persist(Object)
*/ */

View File

@ -53,7 +53,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
import org.hibernate.ejb.AvailableSettings; import org.hibernate.jpa.AvailableSettings;
import org.hibernate.jpa.internal.EntityManagerMessageLogger; import org.hibernate.jpa.internal.EntityManagerMessageLogger;
import org.hibernate.jpa.packaging.internal.JarVisitorFactory; import org.hibernate.jpa.packaging.internal.JarVisitorFactory;
import org.hibernate.jpa.internal.util.ConfigurationHelper; import org.hibernate.jpa.internal.util.ConfigurationHelper;
@ -397,7 +397,7 @@ public class PersistenceXmlParser {
private Schema v2Schema() { private Schema v2Schema() {
if ( v2Schema == null ) { if ( v2Schema == null ) {
v2Schema = resolveLocalSchema( "org/hibernate/ejb/persistence_2_0.xsd" ); v2Schema = resolveLocalSchema( "org/hibernate/jpa/persistence_2_0.xsd" );
} }
return v2Schema; return v2Schema;
} }
@ -406,7 +406,7 @@ public class PersistenceXmlParser {
private Schema v1Schema() { private Schema v1Schema() {
if ( v1Schema == null ) { if ( v1Schema == null ) {
v1Schema = resolveLocalSchema( "org/hibernate/ejb/persistence_1_0.xsd" ); v1Schema = resolveLocalSchema( "org/hibernate/jpa/persistence_1_0.xsd" );
} }
return v1Schema; return v1Schema;
} }

View File

@ -35,16 +35,18 @@ import org.hibernate.event.spi.AutoFlushEventListener;
* *
* @author Gavin King * @author Gavin King
*/ */
public class EJB3AutoFlushEventListener public class JpaAutoFlushEventListener
extends DefaultAutoFlushEventListener extends DefaultAutoFlushEventListener
implements HibernateEntityManagerEventListener { implements HibernateEntityManagerEventListener {
public static final AutoFlushEventListener INSTANCE = new EJB3AutoFlushEventListener(); public static final AutoFlushEventListener INSTANCE = new JpaAutoFlushEventListener();
@Override
protected CascadingAction getCascadingAction() { protected CascadingAction getCascadingAction() {
return CascadingAction.PERSIST_ON_FLUSH; return CascadingAction.PERSIST_ON_FLUSH;
} }
@Override
protected Object getAnything() { protected Object getAnything() {
return new IdentityHashMap( 10 ); return new IdentityHashMap( 10 );
} }

View File

@ -35,18 +35,18 @@ import org.hibernate.persister.entity.EntityPersister;
* *
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
public class EJB3DeleteEventListener extends DefaultDeleteEventListener implements CallbackHandlerConsumer { public class JpaDeleteEventListener extends DefaultDeleteEventListener implements CallbackHandlerConsumer {
private EntityCallbackHandler callbackHandler; private EntityCallbackHandler callbackHandler;
public void setCallbackHandler(EntityCallbackHandler callbackHandler) { public void setCallbackHandler(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
public EJB3DeleteEventListener() { public JpaDeleteEventListener() {
super(); super();
} }
public EJB3DeleteEventListener(EntityCallbackHandler callbackHandler) { public JpaDeleteEventListener(EntityCallbackHandler callbackHandler) {
this(); this();
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }

View File

@ -37,18 +37,18 @@ import org.hibernate.type.Type;
* *
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
public class EJB3FlushEntityEventListener extends DefaultFlushEntityEventListener implements CallbackHandlerConsumer { public class JpaFlushEntityEventListener extends DefaultFlushEntityEventListener implements CallbackHandlerConsumer {
private EntityCallbackHandler callbackHandler; private EntityCallbackHandler callbackHandler;
public void setCallbackHandler(EntityCallbackHandler callbackHandler) { public void setCallbackHandler(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
public EJB3FlushEntityEventListener() { public JpaFlushEntityEventListener() {
super(); super();
} }
public EJB3FlushEntityEventListener(EntityCallbackHandler callbackHandler) { public JpaFlushEntityEventListener(EntityCallbackHandler callbackHandler) {
super(); super();
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }

View File

@ -30,19 +30,20 @@ import org.hibernate.event.internal.DefaultFlushEventListener;
import org.hibernate.event.spi.FlushEventListener; import org.hibernate.event.spi.FlushEventListener;
/** /**
* In EJB3, it is the create operation that is cascaded to unmanaged entities at flush time (instead of the * In JPA, it is the create operation that is cascaded to unmanaged entities at flush time (instead of the
* save-update operation in Hibernate). * save-update operation in Hibernate).
* *
* @author Gavin King * @author Gavin King
*/ */
public class EJB3FlushEventListener extends DefaultFlushEventListener implements HibernateEntityManagerEventListener { public class JpaFlushEventListener extends DefaultFlushEventListener implements HibernateEntityManagerEventListener {
public static final FlushEventListener INSTANCE = new JpaFlushEventListener();
public static final FlushEventListener INSTANCE = new EJB3FlushEventListener();
@Override
protected CascadingAction getCascadingAction() { protected CascadingAction getCascadingAction() {
return CascadingAction.PERSIST_ON_FLUSH; return CascadingAction.PERSIST_ON_FLUSH;
} }
@Override
protected Object getAnything() { protected Object getAnything() {
return new IdentityHashMap( 10 ); return new IdentityHashMap( 10 );
} }

View File

@ -97,15 +97,15 @@ public class JpaIntegrator implements Integrator {
eventListenerRegistry.addDuplicationStrategy( JACC_DUPLICATION_STRATEGY ); eventListenerRegistry.addDuplicationStrategy( JACC_DUPLICATION_STRATEGY );
// op listeners // op listeners
eventListenerRegistry.setListeners( EventType.AUTO_FLUSH, EJB3AutoFlushEventListener.INSTANCE ); eventListenerRegistry.setListeners( EventType.AUTO_FLUSH, JpaAutoFlushEventListener.INSTANCE );
eventListenerRegistry.setListeners( EventType.DELETE, new EJB3DeleteEventListener() ); eventListenerRegistry.setListeners( EventType.DELETE, new JpaDeleteEventListener() );
eventListenerRegistry.setListeners( EventType.FLUSH_ENTITY, new EJB3FlushEntityEventListener() ); eventListenerRegistry.setListeners( EventType.FLUSH_ENTITY, new JpaFlushEntityEventListener() );
eventListenerRegistry.setListeners( EventType.FLUSH, EJB3FlushEventListener.INSTANCE ); eventListenerRegistry.setListeners( EventType.FLUSH, JpaFlushEventListener.INSTANCE );
eventListenerRegistry.setListeners( EventType.MERGE, new EJB3MergeEventListener() ); eventListenerRegistry.setListeners( EventType.MERGE, new JpaMergeEventListener() );
eventListenerRegistry.setListeners( EventType.PERSIST, new EJB3PersistEventListener() ); eventListenerRegistry.setListeners( EventType.PERSIST, new JpaPersistEventListener() );
eventListenerRegistry.setListeners( EventType.PERSIST_ONFLUSH, new EJB3PersistOnFlushEventListener() ); eventListenerRegistry.setListeners( EventType.PERSIST_ONFLUSH, new JpaPersistOnFlushEventListener() );
eventListenerRegistry.setListeners( EventType.SAVE, new EJB3SaveEventListener() ); eventListenerRegistry.setListeners( EventType.SAVE, new JpaSaveEventListener() );
eventListenerRegistry.setListeners( EventType.SAVE_UPDATE, new EJB3SaveOrUpdateEventListener() ); eventListenerRegistry.setListeners( EventType.SAVE_UPDATE, new JpaSaveOrUpdateEventListener() );
// pre op listeners // pre op listeners
if ( isSecurityEnabled ) { if ( isSecurityEnabled ) {
@ -117,10 +117,10 @@ public class JpaIntegrator implements Integrator {
} }
// post op listeners // post op listeners
eventListenerRegistry.prependListeners( EventType.POST_DELETE, new EJB3PostDeleteEventListener() ); eventListenerRegistry.prependListeners( EventType.POST_DELETE, new JpaPostDeleteEventListener() );
eventListenerRegistry.prependListeners( EventType.POST_INSERT, new EJB3PostInsertEventListener() ); eventListenerRegistry.prependListeners( EventType.POST_INSERT, new JpaPostInsertEventListener() );
eventListenerRegistry.prependListeners( EventType.POST_LOAD, new EJB3PostLoadEventListener() ); eventListenerRegistry.prependListeners( EventType.POST_LOAD, new JpaPostLoadEventListener() );
eventListenerRegistry.prependListeners( EventType.POST_UPDATE, new EJB3PostUpdateEventListener() ); eventListenerRegistry.prependListeners( EventType.POST_UPDATE, new JpaPostUpdateEventListener() );
for ( Map.Entry<?,?> entry : configuration.getProperties().entrySet() ) { for ( Map.Entry<?,?> entry : configuration.getProperties().entrySet() ) {
if ( ! String.class.isInstance( entry.getKey() ) ) { if ( ! String.class.isInstance( entry.getKey() ) ) {
@ -182,15 +182,15 @@ public class JpaIntegrator implements Integrator {
eventListenerRegistry.addDuplicationStrategy( JACC_DUPLICATION_STRATEGY ); eventListenerRegistry.addDuplicationStrategy( JACC_DUPLICATION_STRATEGY );
// op listeners // op listeners
eventListenerRegistry.setListeners( EventType.AUTO_FLUSH, EJB3AutoFlushEventListener.INSTANCE ); eventListenerRegistry.setListeners( EventType.AUTO_FLUSH, JpaAutoFlushEventListener.INSTANCE );
eventListenerRegistry.setListeners( EventType.DELETE, new EJB3DeleteEventListener() ); eventListenerRegistry.setListeners( EventType.DELETE, new JpaDeleteEventListener() );
eventListenerRegistry.setListeners( EventType.FLUSH_ENTITY, new EJB3FlushEntityEventListener() ); eventListenerRegistry.setListeners( EventType.FLUSH_ENTITY, new JpaFlushEntityEventListener() );
eventListenerRegistry.setListeners( EventType.FLUSH, EJB3FlushEventListener.INSTANCE ); eventListenerRegistry.setListeners( EventType.FLUSH, JpaFlushEventListener.INSTANCE );
eventListenerRegistry.setListeners( EventType.MERGE, new EJB3MergeEventListener() ); eventListenerRegistry.setListeners( EventType.MERGE, new JpaMergeEventListener() );
eventListenerRegistry.setListeners( EventType.PERSIST, new EJB3PersistEventListener() ); eventListenerRegistry.setListeners( EventType.PERSIST, new JpaPersistEventListener() );
eventListenerRegistry.setListeners( EventType.PERSIST_ONFLUSH, new EJB3PersistOnFlushEventListener() ); eventListenerRegistry.setListeners( EventType.PERSIST_ONFLUSH, new JpaPersistOnFlushEventListener() );
eventListenerRegistry.setListeners( EventType.SAVE, new EJB3SaveEventListener() ); eventListenerRegistry.setListeners( EventType.SAVE, new JpaSaveEventListener() );
eventListenerRegistry.setListeners( EventType.SAVE_UPDATE, new EJB3SaveOrUpdateEventListener() ); eventListenerRegistry.setListeners( EventType.SAVE_UPDATE, new JpaSaveOrUpdateEventListener() );
// pre op listeners // pre op listeners
if ( isSecurityEnabled ) { if ( isSecurityEnabled ) {
@ -202,10 +202,10 @@ public class JpaIntegrator implements Integrator {
} }
// post op listeners // post op listeners
eventListenerRegistry.prependListeners( EventType.POST_DELETE, new EJB3PostDeleteEventListener() ); eventListenerRegistry.prependListeners( EventType.POST_DELETE, new JpaPostDeleteEventListener() );
eventListenerRegistry.prependListeners( EventType.POST_INSERT, new EJB3PostInsertEventListener() ); eventListenerRegistry.prependListeners( EventType.POST_INSERT, new JpaPostInsertEventListener() );
eventListenerRegistry.prependListeners( EventType.POST_LOAD, new EJB3PostLoadEventListener() ); eventListenerRegistry.prependListeners( EventType.POST_LOAD, new JpaPostLoadEventListener() );
eventListenerRegistry.prependListeners( EventType.POST_UPDATE, new EJB3PostUpdateEventListener() ); eventListenerRegistry.prependListeners( EventType.POST_UPDATE, new JpaPostUpdateEventListener() );
for ( Map.Entry<?,?> entry : sessionFactory.getProperties().entrySet() ) { for ( Map.Entry<?,?> entry : sessionFactory.getProperties().entrySet() ) {
if ( ! String.class.isInstance( entry.getKey() ) ) { if ( ! String.class.isInstance( entry.getKey() ) ) {

View File

@ -33,18 +33,18 @@ import org.hibernate.event.spi.EventSource;
* *
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
public class EJB3MergeEventListener extends DefaultMergeEventListener implements CallbackHandlerConsumer { public class JpaMergeEventListener extends DefaultMergeEventListener implements CallbackHandlerConsumer {
private EntityCallbackHandler callbackHandler; private EntityCallbackHandler callbackHandler;
public void setCallbackHandler(EntityCallbackHandler callbackHandler) { public void setCallbackHandler(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
public EJB3MergeEventListener() { public JpaMergeEventListener() {
super(); super();
} }
public EJB3MergeEventListener(EntityCallbackHandler callbackHandler) { public JpaMergeEventListener(EntityCallbackHandler callbackHandler) {
super(); super();
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }

View File

@ -26,8 +26,8 @@ package org.hibernate.jpa.internal.event;
import java.io.Serializable; import java.io.Serializable;
import org.hibernate.engine.spi.CascadingAction; import org.hibernate.engine.spi.CascadingAction;
import org.hibernate.engine.spi.EJB3CascadeStyle; import org.hibernate.engine.spi.JpaCascadeStyle;
import org.hibernate.engine.spi.EJB3CascadingAction; import org.hibernate.engine.spi.JpaCascadingAction;
import org.hibernate.event.internal.DefaultPersistEventListener; import org.hibernate.event.internal.DefaultPersistEventListener;
import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.EventSource;
@ -36,22 +36,23 @@ import org.hibernate.event.spi.EventSource;
* *
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
public class EJB3PersistEventListener extends DefaultPersistEventListener implements CallbackHandlerConsumer { public class JpaPersistEventListener extends DefaultPersistEventListener implements CallbackHandlerConsumer {
static { static {
EJB3CascadeStyle.PERSIST_EJB3.hasOrphanDelete(); //triggers class loading to override persist with PERSIST_EJB3 JpaCascadeStyle.PERSIST_JPA.hasOrphanDelete(); //triggers class loading to override persist with PERSIST_JPA
} }
private EntityCallbackHandler callbackHandler; private EntityCallbackHandler callbackHandler;
@Override
public void setCallbackHandler(EntityCallbackHandler callbackHandler) { public void setCallbackHandler(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
public EJB3PersistEventListener() { public JpaPersistEventListener() {
super(); super();
} }
public EJB3PersistEventListener(EntityCallbackHandler callbackHandler) { public JpaPersistEventListener(EntityCallbackHandler callbackHandler) {
super(); super();
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
@ -80,6 +81,6 @@ public class EJB3PersistEventListener extends DefaultPersistEventListener implem
@Override @Override
protected CascadingAction getCascadeAction() { protected CascadingAction getCascadeAction() {
return EJB3CascadingAction.PERSIST_SKIPLAZY; return JpaCascadingAction.PERSIST_SKIPLAZY;
} }
} }

View File

@ -28,7 +28,7 @@ import org.hibernate.engine.spi.CascadingAction;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
public class EJB3PersistOnFlushEventListener extends EJB3PersistEventListener { public class JpaPersistOnFlushEventListener extends JpaPersistEventListener {
@Override @Override
protected CascadingAction getCascadeAction() { protected CascadingAction getCascadeAction() {
return CascadingAction.PERSIST_ON_FLUSH; return CascadingAction.PERSIST_ON_FLUSH;

View File

@ -29,18 +29,18 @@ import org.hibernate.event.spi.PostDeleteEventListener;
/** /**
* @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a> * @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
*/ */
public class EJB3PostDeleteEventListener implements PostDeleteEventListener, CallbackHandlerConsumer { public class JpaPostDeleteEventListener implements PostDeleteEventListener, CallbackHandlerConsumer {
EntityCallbackHandler callbackHandler; EntityCallbackHandler callbackHandler;
public void setCallbackHandler(EntityCallbackHandler callbackHandler) { public void setCallbackHandler(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
public EJB3PostDeleteEventListener() { public JpaPostDeleteEventListener() {
super(); super();
} }
public EJB3PostDeleteEventListener(EntityCallbackHandler callbackHandler) { public JpaPostDeleteEventListener(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }

View File

@ -29,21 +29,23 @@ import org.hibernate.event.spi.PostInsertEventListener;
/** /**
* @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a> * @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
*/ */
public class EJB3PostInsertEventListener implements PostInsertEventListener, CallbackHandlerConsumer { public class JpaPostInsertEventListener implements PostInsertEventListener, CallbackHandlerConsumer {
EntityCallbackHandler callbackHandler; EntityCallbackHandler callbackHandler;
@Override
public void setCallbackHandler(EntityCallbackHandler callbackHandler) { public void setCallbackHandler(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
public EJB3PostInsertEventListener() { public JpaPostInsertEventListener() {
super(); super();
} }
public EJB3PostInsertEventListener(EntityCallbackHandler callbackHandler) { public JpaPostInsertEventListener(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
@Override
public void onPostInsert(PostInsertEvent event) { public void onPostInsert(PostInsertEvent event) {
Object entity = event.getEntity(); Object entity = event.getEntity();
callbackHandler.postCreate( entity ); callbackHandler.postCreate( entity );

View File

@ -29,21 +29,23 @@ import org.hibernate.event.spi.PostLoadEventListener;
/** /**
* @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a> * @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
*/ */
public class EJB3PostLoadEventListener implements PostLoadEventListener, CallbackHandlerConsumer { public class JpaPostLoadEventListener implements PostLoadEventListener, CallbackHandlerConsumer {
EntityCallbackHandler callbackHandler; EntityCallbackHandler callbackHandler;
@Override
public void setCallbackHandler(EntityCallbackHandler callbackHandler) { public void setCallbackHandler(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
public EJB3PostLoadEventListener() { public JpaPostLoadEventListener() {
super(); super();
} }
public EJB3PostLoadEventListener(EntityCallbackHandler callbackHandler) { public JpaPostLoadEventListener(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
@Override
public void onPostLoad(PostLoadEvent event) { public void onPostLoad(PostLoadEvent event) {
Object entity = event.getEntity(); Object entity = event.getEntity();
callbackHandler.postLoad( entity ); callbackHandler.postLoad( entity );

View File

@ -41,7 +41,7 @@ import org.hibernate.event.spi.PostUpdateEventListener;
* @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a> * @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class EJB3PostUpdateEventListener public class JpaPostUpdateEventListener
implements PostUpdateEventListener, implements PostUpdateEventListener,
CallbackHandlerConsumer, CallbackHandlerConsumer,
PostCollectionRecreateEventListener, PostCollectionRecreateEventListener,
@ -49,18 +49,20 @@ public class EJB3PostUpdateEventListener
PostCollectionUpdateEventListener { PostCollectionUpdateEventListener {
EntityCallbackHandler callbackHandler; EntityCallbackHandler callbackHandler;
@Override
public void setCallbackHandler(EntityCallbackHandler callbackHandler) { public void setCallbackHandler(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
public EJB3PostUpdateEventListener() { public JpaPostUpdateEventListener() {
super(); super();
} }
public EJB3PostUpdateEventListener(EntityCallbackHandler callbackHandler) { public JpaPostUpdateEventListener(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
@Override
public void onPostUpdate(PostUpdateEvent event) { public void onPostUpdate(PostUpdateEvent event) {
Object entity = event.getEntity(); Object entity = event.getEntity();
EventSource eventSource = event.getSession(); EventSource eventSource = event.getSession();
@ -76,18 +78,21 @@ public class EJB3PostUpdateEventListener
} }
} }
@Override
public void onPostRecreateCollection(PostCollectionRecreateEvent event) { public void onPostRecreateCollection(PostCollectionRecreateEvent event) {
Object entity = event.getCollection().getOwner(); Object entity = event.getCollection().getOwner();
EventSource eventSource = event.getSession(); EventSource eventSource = event.getSession();
handlePostUpdate(entity, eventSource); handlePostUpdate(entity, eventSource);
} }
@Override
public void onPostRemoveCollection(PostCollectionRemoveEvent event) { public void onPostRemoveCollection(PostCollectionRemoveEvent event) {
Object entity = event.getCollection().getOwner(); Object entity = event.getCollection().getOwner();
EventSource eventSource = event.getSession(); EventSource eventSource = event.getSession();
handlePostUpdate(entity, eventSource); handlePostUpdate(entity, eventSource);
} }
@Override
public void onPostUpdateCollection(PostCollectionUpdateEvent event) { public void onPostUpdateCollection(PostCollectionUpdateEvent event) {
Object entity = event.getCollection().getOwner(); Object entity = event.getCollection().getOwner();
EventSource eventSource = event.getSession(); EventSource eventSource = event.getSession();

View File

@ -33,18 +33,18 @@ import org.hibernate.event.spi.EventSource;
* *
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
public class EJB3SaveEventListener extends DefaultSaveEventListener implements CallbackHandlerConsumer { public class JpaSaveEventListener extends DefaultSaveEventListener implements CallbackHandlerConsumer {
private EntityCallbackHandler callbackHandler; private EntityCallbackHandler callbackHandler;
public void setCallbackHandler(EntityCallbackHandler callbackHandler) { public void setCallbackHandler(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
public EJB3SaveEventListener() { public JpaSaveEventListener() {
super(); super();
} }
public EJB3SaveEventListener(EntityCallbackHandler callbackHandler) { public JpaSaveEventListener(EntityCallbackHandler callbackHandler) {
super(); super();
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }

View File

@ -33,18 +33,18 @@ import org.hibernate.event.spi.EventSource;
* *
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
public class EJB3SaveOrUpdateEventListener extends DefaultSaveOrUpdateEventListener implements CallbackHandlerConsumer { public class JpaSaveOrUpdateEventListener extends DefaultSaveOrUpdateEventListener implements CallbackHandlerConsumer {
private EntityCallbackHandler callbackHandler; private EntityCallbackHandler callbackHandler;
public void setCallbackHandler(EntityCallbackHandler callbackHandler) { public void setCallbackHandler(EntityCallbackHandler callbackHandler) {
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }
public EJB3SaveOrUpdateEventListener() { public JpaSaveOrUpdateEventListener() {
super(); super();
} }
public EJB3SaveOrUpdateEventListener(EntityCallbackHandler callbackHandler) { public JpaSaveOrUpdateEventListener(EntityCallbackHandler callbackHandler) {
super(); super();
this.callbackHandler = callbackHandler; this.callbackHandler = callbackHandler;
} }

View File

@ -46,7 +46,7 @@ public class NewBootProcessTest {
@Override @Override
public URL getPersistenceUnitRootUrl() { public URL getPersistenceUnitRootUrl() {
// just get any known url... // just get any known url...
return HibernatePersistenceProvider.class.getResource( "/org/hibernate/ejb/persistence_1_0.xsd" ); return HibernatePersistenceProvider.class.getResource( "/org/hibernate/jpa/persistence_1_0.xsd" );
} }
}, },
settings settings