From 06d44951c62c5c4c02d1d2d77b644f6a9b6ad3a6 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Tue, 17 Jul 2012 18:13:02 -0500 Subject: [PATCH] HHH-7451 - Integrate Draft 7 of the JPA 2.1 spec : more ejb->jpa rename --- .../InjectedDataSourceConnectionProvider.java | 72 --- ...CascadeStyle.java => JpaCascadeStyle.java} | 20 +- ...ingAction.java => JpaCascadingAction.java} | 6 +- .../boot/internal/PersistenceXmlParser.java | 6 +- ...er.java => JpaAutoFlushEventListener.java} | 6 +- ...tener.java => JpaDeleteEventListener.java} | 6 +- ....java => JpaFlushEntityEventListener.java} | 6 +- ...stener.java => JpaFlushEventListener.java} | 9 +- .../jpa/internal/event/JpaIntegrator.java | 52 +- ...stener.java => JpaMergeEventListener.java} | 6 +- ...ener.java => JpaPersistEventListener.java} | 15 +- ...va => JpaPersistOnFlushEventListener.java} | 2 +- ...r.java => JpaPostDeleteEventListener.java} | 6 +- ...r.java => JpaPostInsertEventListener.java} | 8 +- ...ner.java => JpaPostLoadEventListener.java} | 8 +- ...r.java => JpaPostUpdateEventListener.java} | 11 +- ...istener.java => JpaSaveEventListener.java} | 6 +- ...java => JpaSaveOrUpdateEventListener.java} | 6 +- .../{ejb => jpa}/persistence_1_0.xsd | 520 +++++++++--------- .../{ejb => jpa}/persistence_2_0.xsd | 0 .../ejb/test/boot/NewBootProcessTest.java | 2 +- 21 files changed, 357 insertions(+), 416 deletions(-) delete mode 100644 hibernate-entitymanager/src/main/java/org/hibernate/ejb/connection/InjectedDataSourceConnectionProvider.java rename hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/{EJB3CascadeStyle.java => JpaCascadeStyle.java} (67%) rename hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/{EJB3CascadingAction.java => JpaCascadingAction.java} (86%) rename hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/{EJB3AutoFlushEventListener.java => JpaAutoFlushEventListener.java} (92%) rename hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/{EJB3DeleteEventListener.java => JpaDeleteEventListener.java} (91%) rename hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/{EJB3FlushEntityEventListener.java => JpaFlushEntityEventListener.java} (92%) rename hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/{EJB3FlushEventListener.java => JpaFlushEventListener.java} (82%) rename hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/{EJB3MergeEventListener.java => JpaMergeEventListener.java} (91%) rename hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/{EJB3PersistEventListener.java => JpaPersistEventListener.java} (82%) rename hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/{EJB3PersistOnFlushEventListener.java => JpaPersistOnFlushEventListener.java} (94%) rename hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/{EJB3PostDeleteEventListener.java => JpaPostDeleteEventListener.java} (88%) rename hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/{EJB3PostInsertEventListener.java => JpaPostInsertEventListener.java} (87%) rename hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/{EJB3PostLoadEventListener.java => JpaPostLoadEventListener.java} (87%) rename hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/{EJB3PostUpdateEventListener.java => JpaPostUpdateEventListener.java} (94%) rename hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/{EJB3SaveEventListener.java => JpaSaveEventListener.java} (91%) rename hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/{EJB3SaveOrUpdateEventListener.java => JpaSaveOrUpdateEventListener.java} (90%) rename hibernate-entitymanager/src/main/resources/org/hibernate/{ejb => jpa}/persistence_1_0.xsd (97%) rename hibernate-entitymanager/src/main/resources/org/hibernate/{ejb => jpa}/persistence_2_0.xsd (100%) diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/ejb/connection/InjectedDataSourceConnectionProvider.java b/hibernate-entitymanager/src/main/java/org/hibernate/ejb/connection/InjectedDataSourceConnectionProvider.java deleted file mode 100644 index 0b11321edd..0000000000 --- a/hibernate-entitymanager/src/main/java/org/hibernate/ejb/connection/InjectedDataSourceConnectionProvider.java +++ /dev/null @@ -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. - *

- * NOTE : {@link #setDataSource} must be called prior to {@link #configure}. - *

- * 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(); - } -} diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/EJB3CascadeStyle.java b/hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/JpaCascadeStyle.java similarity index 67% rename from hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/EJB3CascadeStyle.java rename to hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/JpaCascadeStyle.java index b5903bed8d..2b1b515161 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/EJB3CascadeStyle.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/JpaCascadeStyle.java @@ -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 * 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, * copy, or redistribute it subject to the terms and conditions of the GNU @@ -22,23 +24,23 @@ 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 * - * 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 * * @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) { - return action== EJB3CascadingAction.PERSIST_SKIPLAZY + return action== JpaCascadingAction.PERSIST_SKIPLAZY || action==CascadingAction.PERSIST_ON_FLUSH; } public String toString() { @@ -47,6 +49,6 @@ public abstract class EJB3CascadeStyle extends CascadeStyle { }; static { - STYLES.put( "persist", PERSIST_EJB3 ); + STYLES.put( "persist", PERSIST_JPA ); } } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/EJB3CascadingAction.java b/hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/JpaCascadingAction.java similarity index 86% rename from hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/EJB3CascadingAction.java rename to hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/JpaCascadingAction.java index 27fd03d06e..99da8ad2ba 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/EJB3CascadingAction.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/engine/spi/JpaCascadingAction.java @@ -27,7 +27,6 @@ import java.util.Map; import org.jboss.logging.Logger; import org.hibernate.HibernateException; -import org.hibernate.jpa.internal.EntityManagerMessageLogger; import org.hibernate.event.spi.EventSource; import org.hibernate.type.CollectionType; @@ -37,10 +36,9 @@ import org.hibernate.type.CollectionType; * TODO Get rid of it for 3.3 * @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) */ diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/PersistenceXmlParser.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/PersistenceXmlParser.java index ce732456bf..60aff1bc0b 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/PersistenceXmlParser.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/PersistenceXmlParser.java @@ -53,7 +53,7 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; 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.packaging.internal.JarVisitorFactory; import org.hibernate.jpa.internal.util.ConfigurationHelper; @@ -397,7 +397,7 @@ public class PersistenceXmlParser { private Schema v2Schema() { if ( v2Schema == null ) { - v2Schema = resolveLocalSchema( "org/hibernate/ejb/persistence_2_0.xsd" ); + v2Schema = resolveLocalSchema( "org/hibernate/jpa/persistence_2_0.xsd" ); } return v2Schema; } @@ -406,7 +406,7 @@ public class PersistenceXmlParser { private Schema v1Schema() { if ( v1Schema == null ) { - v1Schema = resolveLocalSchema( "org/hibernate/ejb/persistence_1_0.xsd" ); + v1Schema = resolveLocalSchema( "org/hibernate/jpa/persistence_1_0.xsd" ); } return v1Schema; } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3AutoFlushEventListener.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaAutoFlushEventListener.java similarity index 92% rename from hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3AutoFlushEventListener.java rename to hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaAutoFlushEventListener.java index 48b4934f92..b55ca1a5e8 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3AutoFlushEventListener.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaAutoFlushEventListener.java @@ -35,16 +35,18 @@ import org.hibernate.event.spi.AutoFlushEventListener; * * @author Gavin King */ -public class EJB3AutoFlushEventListener +public class JpaAutoFlushEventListener extends DefaultAutoFlushEventListener implements HibernateEntityManagerEventListener { - public static final AutoFlushEventListener INSTANCE = new EJB3AutoFlushEventListener(); + public static final AutoFlushEventListener INSTANCE = new JpaAutoFlushEventListener(); + @Override protected CascadingAction getCascadingAction() { return CascadingAction.PERSIST_ON_FLUSH; } + @Override protected Object getAnything() { return new IdentityHashMap( 10 ); } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3DeleteEventListener.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaDeleteEventListener.java similarity index 91% rename from hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3DeleteEventListener.java rename to hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaDeleteEventListener.java index cf8b578cd0..8c98271cc9 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3DeleteEventListener.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaDeleteEventListener.java @@ -35,18 +35,18 @@ import org.hibernate.persister.entity.EntityPersister; * * @author Emmanuel Bernard */ -public class EJB3DeleteEventListener extends DefaultDeleteEventListener implements CallbackHandlerConsumer { +public class JpaDeleteEventListener extends DefaultDeleteEventListener implements CallbackHandlerConsumer { private EntityCallbackHandler callbackHandler; public void setCallbackHandler(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } - public EJB3DeleteEventListener() { + public JpaDeleteEventListener() { super(); } - public EJB3DeleteEventListener(EntityCallbackHandler callbackHandler) { + public JpaDeleteEventListener(EntityCallbackHandler callbackHandler) { this(); this.callbackHandler = callbackHandler; } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3FlushEntityEventListener.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaFlushEntityEventListener.java similarity index 92% rename from hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3FlushEntityEventListener.java rename to hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaFlushEntityEventListener.java index 52b3eb6ad0..e7f162684e 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3FlushEntityEventListener.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaFlushEntityEventListener.java @@ -37,18 +37,18 @@ import org.hibernate.type.Type; * * @author Emmanuel Bernard */ -public class EJB3FlushEntityEventListener extends DefaultFlushEntityEventListener implements CallbackHandlerConsumer { +public class JpaFlushEntityEventListener extends DefaultFlushEntityEventListener implements CallbackHandlerConsumer { private EntityCallbackHandler callbackHandler; public void setCallbackHandler(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } - public EJB3FlushEntityEventListener() { + public JpaFlushEntityEventListener() { super(); } - public EJB3FlushEntityEventListener(EntityCallbackHandler callbackHandler) { + public JpaFlushEntityEventListener(EntityCallbackHandler callbackHandler) { super(); this.callbackHandler = callbackHandler; } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3FlushEventListener.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaFlushEventListener.java similarity index 82% rename from hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3FlushEventListener.java rename to hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaFlushEventListener.java index 74ea2cc2e8..836489a259 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3FlushEventListener.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaFlushEventListener.java @@ -30,19 +30,20 @@ import org.hibernate.event.internal.DefaultFlushEventListener; 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). * * @author Gavin King */ -public class EJB3FlushEventListener extends DefaultFlushEventListener implements HibernateEntityManagerEventListener { - - public static final FlushEventListener INSTANCE = new EJB3FlushEventListener(); +public class JpaFlushEventListener extends DefaultFlushEventListener implements HibernateEntityManagerEventListener { + public static final FlushEventListener INSTANCE = new JpaFlushEventListener(); + @Override protected CascadingAction getCascadingAction() { return CascadingAction.PERSIST_ON_FLUSH; } + @Override protected Object getAnything() { return new IdentityHashMap( 10 ); } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaIntegrator.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaIntegrator.java index 8422f3980d..cdc26a8780 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaIntegrator.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaIntegrator.java @@ -97,15 +97,15 @@ public class JpaIntegrator implements Integrator { eventListenerRegistry.addDuplicationStrategy( JACC_DUPLICATION_STRATEGY ); // op listeners - eventListenerRegistry.setListeners( EventType.AUTO_FLUSH, EJB3AutoFlushEventListener.INSTANCE ); - eventListenerRegistry.setListeners( EventType.DELETE, new EJB3DeleteEventListener() ); - eventListenerRegistry.setListeners( EventType.FLUSH_ENTITY, new EJB3FlushEntityEventListener() ); - eventListenerRegistry.setListeners( EventType.FLUSH, EJB3FlushEventListener.INSTANCE ); - eventListenerRegistry.setListeners( EventType.MERGE, new EJB3MergeEventListener() ); - eventListenerRegistry.setListeners( EventType.PERSIST, new EJB3PersistEventListener() ); - eventListenerRegistry.setListeners( EventType.PERSIST_ONFLUSH, new EJB3PersistOnFlushEventListener() ); - eventListenerRegistry.setListeners( EventType.SAVE, new EJB3SaveEventListener() ); - eventListenerRegistry.setListeners( EventType.SAVE_UPDATE, new EJB3SaveOrUpdateEventListener() ); + eventListenerRegistry.setListeners( EventType.AUTO_FLUSH, JpaAutoFlushEventListener.INSTANCE ); + eventListenerRegistry.setListeners( EventType.DELETE, new JpaDeleteEventListener() ); + eventListenerRegistry.setListeners( EventType.FLUSH_ENTITY, new JpaFlushEntityEventListener() ); + eventListenerRegistry.setListeners( EventType.FLUSH, JpaFlushEventListener.INSTANCE ); + eventListenerRegistry.setListeners( EventType.MERGE, new JpaMergeEventListener() ); + eventListenerRegistry.setListeners( EventType.PERSIST, new JpaPersistEventListener() ); + eventListenerRegistry.setListeners( EventType.PERSIST_ONFLUSH, new JpaPersistOnFlushEventListener() ); + eventListenerRegistry.setListeners( EventType.SAVE, new JpaSaveEventListener() ); + eventListenerRegistry.setListeners( EventType.SAVE_UPDATE, new JpaSaveOrUpdateEventListener() ); // pre op listeners if ( isSecurityEnabled ) { @@ -117,10 +117,10 @@ public class JpaIntegrator implements Integrator { } // post op listeners - eventListenerRegistry.prependListeners( EventType.POST_DELETE, new EJB3PostDeleteEventListener() ); - eventListenerRegistry.prependListeners( EventType.POST_INSERT, new EJB3PostInsertEventListener() ); - eventListenerRegistry.prependListeners( EventType.POST_LOAD, new EJB3PostLoadEventListener() ); - eventListenerRegistry.prependListeners( EventType.POST_UPDATE, new EJB3PostUpdateEventListener() ); + eventListenerRegistry.prependListeners( EventType.POST_DELETE, new JpaPostDeleteEventListener() ); + eventListenerRegistry.prependListeners( EventType.POST_INSERT, new JpaPostInsertEventListener() ); + eventListenerRegistry.prependListeners( EventType.POST_LOAD, new JpaPostLoadEventListener() ); + eventListenerRegistry.prependListeners( EventType.POST_UPDATE, new JpaPostUpdateEventListener() ); for ( Map.Entry entry : configuration.getProperties().entrySet() ) { if ( ! String.class.isInstance( entry.getKey() ) ) { @@ -182,15 +182,15 @@ public class JpaIntegrator implements Integrator { eventListenerRegistry.addDuplicationStrategy( JACC_DUPLICATION_STRATEGY ); // op listeners - eventListenerRegistry.setListeners( EventType.AUTO_FLUSH, EJB3AutoFlushEventListener.INSTANCE ); - eventListenerRegistry.setListeners( EventType.DELETE, new EJB3DeleteEventListener() ); - eventListenerRegistry.setListeners( EventType.FLUSH_ENTITY, new EJB3FlushEntityEventListener() ); - eventListenerRegistry.setListeners( EventType.FLUSH, EJB3FlushEventListener.INSTANCE ); - eventListenerRegistry.setListeners( EventType.MERGE, new EJB3MergeEventListener() ); - eventListenerRegistry.setListeners( EventType.PERSIST, new EJB3PersistEventListener() ); - eventListenerRegistry.setListeners( EventType.PERSIST_ONFLUSH, new EJB3PersistOnFlushEventListener() ); - eventListenerRegistry.setListeners( EventType.SAVE, new EJB3SaveEventListener() ); - eventListenerRegistry.setListeners( EventType.SAVE_UPDATE, new EJB3SaveOrUpdateEventListener() ); + eventListenerRegistry.setListeners( EventType.AUTO_FLUSH, JpaAutoFlushEventListener.INSTANCE ); + eventListenerRegistry.setListeners( EventType.DELETE, new JpaDeleteEventListener() ); + eventListenerRegistry.setListeners( EventType.FLUSH_ENTITY, new JpaFlushEntityEventListener() ); + eventListenerRegistry.setListeners( EventType.FLUSH, JpaFlushEventListener.INSTANCE ); + eventListenerRegistry.setListeners( EventType.MERGE, new JpaMergeEventListener() ); + eventListenerRegistry.setListeners( EventType.PERSIST, new JpaPersistEventListener() ); + eventListenerRegistry.setListeners( EventType.PERSIST_ONFLUSH, new JpaPersistOnFlushEventListener() ); + eventListenerRegistry.setListeners( EventType.SAVE, new JpaSaveEventListener() ); + eventListenerRegistry.setListeners( EventType.SAVE_UPDATE, new JpaSaveOrUpdateEventListener() ); // pre op listeners if ( isSecurityEnabled ) { @@ -202,10 +202,10 @@ public class JpaIntegrator implements Integrator { } // post op listeners - eventListenerRegistry.prependListeners( EventType.POST_DELETE, new EJB3PostDeleteEventListener() ); - eventListenerRegistry.prependListeners( EventType.POST_INSERT, new EJB3PostInsertEventListener() ); - eventListenerRegistry.prependListeners( EventType.POST_LOAD, new EJB3PostLoadEventListener() ); - eventListenerRegistry.prependListeners( EventType.POST_UPDATE, new EJB3PostUpdateEventListener() ); + eventListenerRegistry.prependListeners( EventType.POST_DELETE, new JpaPostDeleteEventListener() ); + eventListenerRegistry.prependListeners( EventType.POST_INSERT, new JpaPostInsertEventListener() ); + eventListenerRegistry.prependListeners( EventType.POST_LOAD, new JpaPostLoadEventListener() ); + eventListenerRegistry.prependListeners( EventType.POST_UPDATE, new JpaPostUpdateEventListener() ); for ( Map.Entry entry : sessionFactory.getProperties().entrySet() ) { if ( ! String.class.isInstance( entry.getKey() ) ) { diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3MergeEventListener.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaMergeEventListener.java similarity index 91% rename from hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3MergeEventListener.java rename to hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaMergeEventListener.java index a570976e2a..ec7bea6bcd 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3MergeEventListener.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaMergeEventListener.java @@ -33,18 +33,18 @@ import org.hibernate.event.spi.EventSource; * * @author Emmanuel Bernard */ -public class EJB3MergeEventListener extends DefaultMergeEventListener implements CallbackHandlerConsumer { +public class JpaMergeEventListener extends DefaultMergeEventListener implements CallbackHandlerConsumer { private EntityCallbackHandler callbackHandler; public void setCallbackHandler(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } - public EJB3MergeEventListener() { + public JpaMergeEventListener() { super(); } - public EJB3MergeEventListener(EntityCallbackHandler callbackHandler) { + public JpaMergeEventListener(EntityCallbackHandler callbackHandler) { super(); this.callbackHandler = callbackHandler; } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PersistEventListener.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPersistEventListener.java similarity index 82% rename from hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PersistEventListener.java rename to hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPersistEventListener.java index 3e08c839c4..4f584d4a1b 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PersistEventListener.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPersistEventListener.java @@ -26,8 +26,8 @@ package org.hibernate.jpa.internal.event; import java.io.Serializable; import org.hibernate.engine.spi.CascadingAction; -import org.hibernate.engine.spi.EJB3CascadeStyle; -import org.hibernate.engine.spi.EJB3CascadingAction; +import org.hibernate.engine.spi.JpaCascadeStyle; +import org.hibernate.engine.spi.JpaCascadingAction; import org.hibernate.event.internal.DefaultPersistEventListener; import org.hibernate.event.spi.EventSource; @@ -36,22 +36,23 @@ import org.hibernate.event.spi.EventSource; * * @author Emmanuel Bernard */ -public class EJB3PersistEventListener extends DefaultPersistEventListener implements CallbackHandlerConsumer { +public class JpaPersistEventListener extends DefaultPersistEventListener implements CallbackHandlerConsumer { 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; + @Override public void setCallbackHandler(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } - public EJB3PersistEventListener() { + public JpaPersistEventListener() { super(); } - public EJB3PersistEventListener(EntityCallbackHandler callbackHandler) { + public JpaPersistEventListener(EntityCallbackHandler callbackHandler) { super(); this.callbackHandler = callbackHandler; } @@ -80,6 +81,6 @@ public class EJB3PersistEventListener extends DefaultPersistEventListener implem @Override protected CascadingAction getCascadeAction() { - return EJB3CascadingAction.PERSIST_SKIPLAZY; + return JpaCascadingAction.PERSIST_SKIPLAZY; } } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PersistOnFlushEventListener.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPersistOnFlushEventListener.java similarity index 94% rename from hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PersistOnFlushEventListener.java rename to hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPersistOnFlushEventListener.java index cf986cd8e6..88a91ed4ce 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PersistOnFlushEventListener.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPersistOnFlushEventListener.java @@ -28,7 +28,7 @@ import org.hibernate.engine.spi.CascadingAction; /** * @author Emmanuel Bernard */ -public class EJB3PersistOnFlushEventListener extends EJB3PersistEventListener { +public class JpaPersistOnFlushEventListener extends JpaPersistEventListener { @Override protected CascadingAction getCascadeAction() { return CascadingAction.PERSIST_ON_FLUSH; diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PostDeleteEventListener.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPostDeleteEventListener.java similarity index 88% rename from hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PostDeleteEventListener.java rename to hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPostDeleteEventListener.java index 490d3356cd..b5e13fd965 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PostDeleteEventListener.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPostDeleteEventListener.java @@ -29,18 +29,18 @@ import org.hibernate.event.spi.PostDeleteEventListener; /** * @author Kabir Khan */ -public class EJB3PostDeleteEventListener implements PostDeleteEventListener, CallbackHandlerConsumer { +public class JpaPostDeleteEventListener implements PostDeleteEventListener, CallbackHandlerConsumer { EntityCallbackHandler callbackHandler; public void setCallbackHandler(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } - public EJB3PostDeleteEventListener() { + public JpaPostDeleteEventListener() { super(); } - public EJB3PostDeleteEventListener(EntityCallbackHandler callbackHandler) { + public JpaPostDeleteEventListener(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PostInsertEventListener.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPostInsertEventListener.java similarity index 87% rename from hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PostInsertEventListener.java rename to hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPostInsertEventListener.java index 20ef83b182..8aa7ad373c 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PostInsertEventListener.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPostInsertEventListener.java @@ -29,21 +29,23 @@ import org.hibernate.event.spi.PostInsertEventListener; /** * @author Kabir Khan */ -public class EJB3PostInsertEventListener implements PostInsertEventListener, CallbackHandlerConsumer { +public class JpaPostInsertEventListener implements PostInsertEventListener, CallbackHandlerConsumer { EntityCallbackHandler callbackHandler; + @Override public void setCallbackHandler(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } - public EJB3PostInsertEventListener() { + public JpaPostInsertEventListener() { super(); } - public EJB3PostInsertEventListener(EntityCallbackHandler callbackHandler) { + public JpaPostInsertEventListener(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } + @Override public void onPostInsert(PostInsertEvent event) { Object entity = event.getEntity(); callbackHandler.postCreate( entity ); diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PostLoadEventListener.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPostLoadEventListener.java similarity index 87% rename from hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PostLoadEventListener.java rename to hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPostLoadEventListener.java index ad0247d28a..6f10739b80 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PostLoadEventListener.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPostLoadEventListener.java @@ -29,21 +29,23 @@ import org.hibernate.event.spi.PostLoadEventListener; /** * @author Kabir Khan */ -public class EJB3PostLoadEventListener implements PostLoadEventListener, CallbackHandlerConsumer { +public class JpaPostLoadEventListener implements PostLoadEventListener, CallbackHandlerConsumer { EntityCallbackHandler callbackHandler; + @Override public void setCallbackHandler(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } - public EJB3PostLoadEventListener() { + public JpaPostLoadEventListener() { super(); } - public EJB3PostLoadEventListener(EntityCallbackHandler callbackHandler) { + public JpaPostLoadEventListener(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } + @Override public void onPostLoad(PostLoadEvent event) { Object entity = event.getEntity(); callbackHandler.postLoad( entity ); diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PostUpdateEventListener.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPostUpdateEventListener.java similarity index 94% rename from hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PostUpdateEventListener.java rename to hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPostUpdateEventListener.java index f25fdbc7c0..83d88675c7 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3PostUpdateEventListener.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaPostUpdateEventListener.java @@ -41,7 +41,7 @@ import org.hibernate.event.spi.PostUpdateEventListener; * @author Kabir Khan */ @SuppressWarnings("serial") -public class EJB3PostUpdateEventListener +public class JpaPostUpdateEventListener implements PostUpdateEventListener, CallbackHandlerConsumer, PostCollectionRecreateEventListener, @@ -49,18 +49,20 @@ public class EJB3PostUpdateEventListener PostCollectionUpdateEventListener { EntityCallbackHandler callbackHandler; + @Override public void setCallbackHandler(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } - public EJB3PostUpdateEventListener() { + public JpaPostUpdateEventListener() { super(); } - public EJB3PostUpdateEventListener(EntityCallbackHandler callbackHandler) { + public JpaPostUpdateEventListener(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } + @Override public void onPostUpdate(PostUpdateEvent event) { Object entity = event.getEntity(); EventSource eventSource = event.getSession(); @@ -76,18 +78,21 @@ public class EJB3PostUpdateEventListener } } + @Override public void onPostRecreateCollection(PostCollectionRecreateEvent event) { Object entity = event.getCollection().getOwner(); EventSource eventSource = event.getSession(); handlePostUpdate(entity, eventSource); } + @Override public void onPostRemoveCollection(PostCollectionRemoveEvent event) { Object entity = event.getCollection().getOwner(); EventSource eventSource = event.getSession(); handlePostUpdate(entity, eventSource); } + @Override public void onPostUpdateCollection(PostCollectionUpdateEvent event) { Object entity = event.getCollection().getOwner(); EventSource eventSource = event.getSession(); diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3SaveEventListener.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaSaveEventListener.java similarity index 91% rename from hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3SaveEventListener.java rename to hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaSaveEventListener.java index a39bfc31a2..8f9c7b145c 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3SaveEventListener.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaSaveEventListener.java @@ -33,18 +33,18 @@ import org.hibernate.event.spi.EventSource; * * @author Emmanuel Bernard */ -public class EJB3SaveEventListener extends DefaultSaveEventListener implements CallbackHandlerConsumer { +public class JpaSaveEventListener extends DefaultSaveEventListener implements CallbackHandlerConsumer { private EntityCallbackHandler callbackHandler; public void setCallbackHandler(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } - public EJB3SaveEventListener() { + public JpaSaveEventListener() { super(); } - public EJB3SaveEventListener(EntityCallbackHandler callbackHandler) { + public JpaSaveEventListener(EntityCallbackHandler callbackHandler) { super(); this.callbackHandler = callbackHandler; } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3SaveOrUpdateEventListener.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaSaveOrUpdateEventListener.java similarity index 90% rename from hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3SaveOrUpdateEventListener.java rename to hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaSaveOrUpdateEventListener.java index cb8b20aa1d..6675764c4c 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/EJB3SaveOrUpdateEventListener.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/event/JpaSaveOrUpdateEventListener.java @@ -33,18 +33,18 @@ import org.hibernate.event.spi.EventSource; * * @author Emmanuel Bernard */ -public class EJB3SaveOrUpdateEventListener extends DefaultSaveOrUpdateEventListener implements CallbackHandlerConsumer { +public class JpaSaveOrUpdateEventListener extends DefaultSaveOrUpdateEventListener implements CallbackHandlerConsumer { private EntityCallbackHandler callbackHandler; public void setCallbackHandler(EntityCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } - public EJB3SaveOrUpdateEventListener() { + public JpaSaveOrUpdateEventListener() { super(); } - public EJB3SaveOrUpdateEventListener(EntityCallbackHandler callbackHandler) { + public JpaSaveOrUpdateEventListener(EntityCallbackHandler callbackHandler) { super(); this.callbackHandler = callbackHandler; } diff --git a/hibernate-entitymanager/src/main/resources/org/hibernate/ejb/persistence_1_0.xsd b/hibernate-entitymanager/src/main/resources/org/hibernate/jpa/persistence_1_0.xsd similarity index 97% rename from hibernate-entitymanager/src/main/resources/org/hibernate/ejb/persistence_1_0.xsd rename to hibernate-entitymanager/src/main/resources/org/hibernate/jpa/persistence_1_0.xsd index 864485497d..9ba0e75e3e 100644 --- a/hibernate-entitymanager/src/main/resources/org/hibernate/ejb/persistence_1_0.xsd +++ b/hibernate-entitymanager/src/main/resources/org/hibernate/jpa/persistence_1_0.xsd @@ -1,260 +1,260 @@ - - - - - - - @(#)persistence_1_0.xsd 1.0 Feb 9 2006 - - - - - ... - - - ]]> - - - - - - - - - - - - - - - - - - - - - - Configuration of a persistence unit. - - - - - - - - - - - - Textual description of this persistence unit. - - - - - - - - - - - - Provider class that supplies EntityManagers for this - persistence unit. - - - - - - - - - - - - The container-specific name of the JTA datasource to use. - - - - - - - - - - - - The container-specific name of a non-JTA datasource to use. - - - - - - - - - - - - File containing mapping information. Loaded as a resource - by the persistence provider. - - - - - - - - - - - - Jar file that should be scanned for entities. - Not applicable to Java SE persistence units. - - - - - - - - - - - - Class to scan for annotations. It should be annotated - with either @Entity, @Embeddable or @MappedSuperclass. - - - - - - - - - - - - When set to true then only listed classes and jars will - be scanned for persistent classes, otherwise the enclosing - jar or directory will also be scanned. Not applicable to - Java SE persistence units. - - - - - - - - - - - - A list of vendor-specific properties. - - - - - - - - - A name-value pair. - - - - - - - - - - - - - - - - - - - - Name used in code to reference this persistence unit. - - - - - - - - - - - - Type of transactions used by EntityManagers from this - persistence unit. - - - - - - - - - - - - - - - - - - - public enum TransactionType { JTA, RESOURCE_LOCAL }; - - - - - - - - - - - + + + + + + + @(#)persistence_1_0.xsd 1.0 Feb 9 2006 + + + + + ... + + + ]]> + + + + + + + + + + + + + + + + + + + + + + Configuration of a persistence unit. + + + + + + + + + + + + Textual description of this persistence unit. + + + + + + + + + + + + Provider class that supplies EntityManagers for this + persistence unit. + + + + + + + + + + + + The container-specific name of the JTA datasource to use. + + + + + + + + + + + + The container-specific name of a non-JTA datasource to use. + + + + + + + + + + + + File containing mapping information. Loaded as a resource + by the persistence provider. + + + + + + + + + + + + Jar file that should be scanned for entities. + Not applicable to Java SE persistence units. + + + + + + + + + + + + Class to scan for annotations. It should be annotated + with either @Entity, @Embeddable or @MappedSuperclass. + + + + + + + + + + + + When set to true then only listed classes and jars will + be scanned for persistent classes, otherwise the enclosing + jar or directory will also be scanned. Not applicable to + Java SE persistence units. + + + + + + + + + + + + A list of vendor-specific properties. + + + + + + + + + A name-value pair. + + + + + + + + + + + + + + + + + + + + Name used in code to reference this persistence unit. + + + + + + + + + + + + Type of transactions used by EntityManagers from this + persistence unit. + + + + + + + + + + + + + + + + + + + public enum TransactionType { JTA, RESOURCE_LOCAL }; + + + + + + + + + + + diff --git a/hibernate-entitymanager/src/main/resources/org/hibernate/ejb/persistence_2_0.xsd b/hibernate-entitymanager/src/main/resources/org/hibernate/jpa/persistence_2_0.xsd similarity index 100% rename from hibernate-entitymanager/src/main/resources/org/hibernate/ejb/persistence_2_0.xsd rename to hibernate-entitymanager/src/main/resources/org/hibernate/jpa/persistence_2_0.xsd diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/boot/NewBootProcessTest.java b/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/boot/NewBootProcessTest.java index 54435ffef5..0834662c45 100644 --- a/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/boot/NewBootProcessTest.java +++ b/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/boot/NewBootProcessTest.java @@ -46,7 +46,7 @@ public class NewBootProcessTest { @Override public URL getPersistenceUnitRootUrl() { // 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