From 07d154fbf2ece9bf4e3c1487aa90da078c77e692 Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Thu, 23 Aug 2012 23:02:51 +0800 Subject: [PATCH 01/38] HHH-7514 fixing compile error --- .../jpa/boot/internal/EntityManagerFactoryBuilderImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java index d4b4113e0a..7518266934 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java @@ -303,7 +303,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil // for now, we also need to wrap this in a CompositeIndex until Jandex is updated to use a common interface // between the 2... - return new CompositeIndex( indexer.complete() ); + return CompositeIndex.create( indexer.complete() ); } private void indexResource(String resourceName, Indexer indexer, BootstrapServiceRegistry bootstrapServiceRegistry) { From 5327ac5396dd742907fb0c01b6d9a9faa6314c8b Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Thu, 23 Aug 2012 01:06:38 -0700 Subject: [PATCH 02/38] HHH-7545 : Aliases for a collection key and element column can collide causing one to be excluded --- .../AbstractCollectionPersister.java | 2 +- .../test/collectionalias/ATable.java | 119 ++++++++++++++++ .../collectionalias/CollectionAliasTest.java | 77 ++++++++++ .../ReorderedMappingsCollectionAliasTest.java | 45 ++++++ .../test/collectionalias/TableA.java | 113 +++++++++++++++ .../test/collectionalias/TableB.java | 118 ++++++++++++++++ .../test/collectionalias/TableBId.java | 133 ++++++++++++++++++ 7 files changed, 606 insertions(+), 1 deletion(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/collectionalias/ATable.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/collectionalias/CollectionAliasTest.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/collectionalias/ReorderedMappingsCollectionAliasTest.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableA.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableB.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableBId.java diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java index 1a505391df..4bddd04438 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java @@ -350,7 +350,7 @@ public abstract class AbstractCollectionPersister iter = collection.getElement().getColumnIterator(); while ( iter.hasNext() ) { Selectable selectable = (Selectable) iter.next(); - elementColumnAliases[j] = selectable.getAlias( dialect ); + elementColumnAliases[j] = selectable.getAlias( dialect, table ); if ( selectable.isFormula() ) { Formula form = (Formula) selectable; elementFormulaTemplates[j] = form.getTemplate( dialect, factory.getSqlFunctionRegistry() ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/ATable.java b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/ATable.java new file mode 100644 index 0000000000..73aaa4ced1 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/ATable.java @@ -0,0 +1,119 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.collectionalias; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +/** + * @author Dave Stephan + */ +@Entity +public class ATable implements Serializable +{ + private Integer firstId; + + private List tablebs = new ArrayList(); + + public ATable() + { + } + + /** minimal constructor */ + public ATable(Integer firstId) + { + this.firstId = firstId; + } + + @Id + @Column(name = "idcolumn", nullable = false) + public Integer getFirstId() + { + return this.firstId; + } + + public void setFirstId(Integer firstId) + { + this.firstId = firstId; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((firstId == null) ? 0 : firstId.hashCode()); + result = prime * result + ((tablebs == null) ? 0 : tablebs.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ATable other = (ATable) obj; + if (firstId == null) + { + if (other.firstId != null) + return false; + } + else if (!firstId.equals(other.firstId)) + return false; + if (tablebs == null) + { + if (other.tablebs != null) + return false; + } + else if (!tablebs.equals(other.tablebs)) + return false; + return true; + } + + + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tablea") + public List getTablebs() + { + return tablebs; + } + + public void setTablebs(List tablebs) + { + this.tablebs = tablebs; + } + + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/CollectionAliasTest.java b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/CollectionAliasTest.java new file mode 100644 index 0000000000..90104b4d98 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/CollectionAliasTest.java @@ -0,0 +1,77 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.collectionalias; + +import org.junit.Test; + +import org.hibernate.Session; +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + +/** + * @author Dave Stephan + * @author Gail Badner + */ +public class CollectionAliasTest extends BaseCoreFunctionalTestCase { + + @TestForIssue( jiraKey = "HHH-7545" ) + @Test + public void test() { + Session s = openSession(); + s.getTransaction().begin(); + ATable aTable = new ATable( 1 ); + TableB tableB = new TableB( + new TableBId( 1, "a", "b" ) + ); + aTable.getTablebs().add( tableB ); + tableB.setTablea( aTable ); + s.save( aTable ); + s.getTransaction().commit(); + s.close(); + + s = openSession(); + aTable = (ATable) s.createQuery( "select distinct tablea from ATable tablea LEFT JOIN FETCH tablea.tablebs " ).uniqueResult(); + assertEquals( new Integer( 1 ), aTable.getFirstId() ); + assertEquals( 1, aTable.getTablebs().size() ); + tableB = aTable.getTablebs().get( 0 ); + assertSame( aTable, tableB.getTablea() ); + assertEquals( new Integer( 1 ), tableB.getId().getFirstId() ); + assertEquals( "a", tableB.getId().getSecondId() ); + assertEquals( "b", tableB.getId().getThirdId() ); + } + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { + TableBId.class, + TableB.class, + TableA.class, + ATable.class + }; + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/ReorderedMappingsCollectionAliasTest.java b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/ReorderedMappingsCollectionAliasTest.java new file mode 100644 index 0000000000..616f528a79 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/ReorderedMappingsCollectionAliasTest.java @@ -0,0 +1,45 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.collectionalias; + +/** + * The bug fixed by HHH-7545 showed showed different results depending on the order + * in which entity mappings were processed. + * + * This mappings are in the opposite order here than in CollectionAliasTest. + * + * @Author Gail Badner + */ +public class ReorderedMappingsCollectionAliasTest extends CollectionAliasTest { + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { + ATable.class, + TableA.class, + TableB.class, + TableBId.class, + }; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableA.java b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableA.java new file mode 100644 index 0000000000..685685d1e4 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableA.java @@ -0,0 +1,113 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.collectionalias; + +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Dave Stephan + */ +@Entity +public class TableA +{ + @Id + private int id; + + private String test; + + private String test2; + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + id; + result = prime * result + ((test == null) ? 0 : test.hashCode()); + result = prime * result + ((test2 == null) ? 0 : test2.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TableA other = (TableA) obj; + if (id != other.id) + return false; + if (test == null) + { + if (other.test != null) + return false; + } + else if (!test.equals(other.test)) + return false; + if (test2 == null) + { + if (other.test2 != null) + return false; + } + else if (!test2.equals(other.test2)) + return false; + return true; + } + + public String getTest2() + { + return test2; + } + + public void setTest2(String test2) + { + this.test2 = test2; + } + + public String getTest() + { + return test; + } + + public void setTest(String test) + { + this.test = test; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableB.java b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableB.java new file mode 100644 index 0000000000..677d44e905 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableB.java @@ -0,0 +1,118 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.collectionalias; + +import java.io.Serializable; + +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.Column; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; + +/** + * @author Dave Stephan + */ +@Entity +public class TableB implements Serializable +{ + + private TableBId id; + + private ATable tablea; + + public TableB() { + } + + /** full constructor */ + public TableB(TableBId id) { + this.id = id; + } + + // Property accessors + @EmbeddedId + @AttributeOverrides( { + @AttributeOverride(name = "firstId", column = @Column(name = "idcolumn", nullable = false)), + @AttributeOverride(name = "secondId", column = @Column(name = "idcolumn_second", nullable = false, length = 50)), + @AttributeOverride(name = "thirdId", column = @Column(name = "thirdcolumn", nullable = false, length = 20)) }) + public TableBId getId() { + return this.id; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((tablea == null) ? 0 : tablea.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TableB other = (TableB) obj; + if (id == null) + { + if (other.id != null) + return false; + } + else if (!id.equals(other.id)) + return false; + if (tablea == null) + { + if (other.tablea != null) + return false; + } + else if (!tablea.equals(other.tablea)) + return false; + return true; + } + + public void setId(TableBId id) { + this.id = id; + } + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumns( { @JoinColumn(name = "idcolumn", referencedColumnName = "idcolumn", nullable = false, insertable = false, updatable = false) }) + public ATable getTablea() { + return tablea; + } + + public void setTablea(ATable tablea) { + this.tablea = tablea; + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableBId.java b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableBId.java new file mode 100644 index 0000000000..3623c7718a --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableBId.java @@ -0,0 +1,133 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.collectionalias; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Embeddable; + +/** + * @author Dave Stephan + */ +@Embeddable +public class TableBId implements Serializable +{ + private static final long serialVersionUID = 1L; + + // Fields + + private Integer firstId; + + private String secondId; + + private String thirdId; + + // Constructors + + /** default constructor */ + public TableBId() { + } + + /** full constructor */ + public TableBId(Integer firstId, String secondId, String thirdId) { + this.firstId = firstId; + this.secondId = secondId; + this.thirdId = thirdId; + } + + // Property accessors + + @Column(name = "idcolumn", nullable = false) + public Integer getFirstId() { + return this.firstId; + } + + public void setFirstId(Integer firstId) { + this.firstId = firstId; + } + + @Column(name = "idcolumn_second", nullable = false, length = 50) + public String getSecondId() { + return this.secondId; + } + + public void setSecondId(String secondId) { + this.secondId = secondId; + } + + @Column(name = "thirdcolumn", nullable = false, length = 50) + public String getThirdId() { + return this.thirdId; + } + + public void setThirdId(String thirdId) { + this.thirdId = thirdId; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((firstId == null) ? 0 : firstId.hashCode()); + result = prime * result + ((secondId == null) ? 0 : secondId.hashCode()); + result = prime * result + ((thirdId == null) ? 0 : thirdId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TableBId other = (TableBId) obj; + if (firstId == null) + { + if (other.firstId != null) + return false; + } + else if (!firstId.equals(other.firstId)) + return false; + if (secondId == null) + { + if (other.secondId != null) + return false; + } + else if (!secondId.equals(other.secondId)) + return false; + if (thirdId == null) + { + if (other.thirdId != null) + return false; + } + else if (!thirdId.equals(other.thirdId)) + return false; + return true; + } +} From edfe8afaf1730b916e823f69f27c7c83ad8ce4e1 Mon Sep 17 00:00:00 2001 From: Lukasz Antoniak Date: Thu, 23 Aug 2012 23:51:46 +0200 Subject: [PATCH 03/38] HHH-7212 - Fix --- .../src/main/java/org/hibernate/envers/tools/Tools.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/tools/Tools.java b/hibernate-envers/src/main/java/org/hibernate/envers/tools/Tools.java index 5c6f09f271..5f388b9075 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/tools/Tools.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/tools/Tools.java @@ -82,7 +82,7 @@ public class Tools { public static Object getTargetFromProxy(SessionFactoryImplementor sessionFactoryImplementor, HibernateProxy proxy) { - if (!proxy.getHibernateLazyInitializer().isUninitialized()) { + if (!proxy.getHibernateLazyInitializer().isUninitialized() || activeProxySession(proxy)) { return proxy.getHibernateLazyInitializer().getImplementation(); } @@ -102,6 +102,11 @@ public class Tools { } } + private static boolean activeProxySession(HibernateProxy proxy) { + Session session = (Session) proxy.getHibernateLazyInitializer().getSession(); + return session != null && session.isOpen() && session.isConnected(); + } + /** * @param clazz Class wrapped with a proxy or not. * @param Class type. From a9c28bf28f7b2c1f97d817c0461fbc5ad3064f56 Mon Sep 17 00:00:00 2001 From: Lukasz Antoniak Date: Fri, 24 Aug 2012 22:30:37 +0200 Subject: [PATCH 04/38] HHH-7543 - Fix and test --- .../EnversPostUpdateEventListenerImpl.java | 14 ++-- .../onetomany/detached/DetachedTest.java | 80 +++++++++++++++++++ 2 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 hibernate-envers/src/test/java/org/hibernate/envers/test/integration/onetomany/detached/DetachedTest.java diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversPostUpdateEventListenerImpl.java b/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversPostUpdateEventListenerImpl.java index 659396ee5b..d14819b3e4 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversPostUpdateEventListenerImpl.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversPostUpdateEventListenerImpl.java @@ -78,12 +78,14 @@ public class EnversPostUpdateEventListenerImpl extends BaseEnversEventListener i private Object[] postUpdateDBState(PostUpdateEvent event) { Object[] newDbState = event.getState().clone(); - EntityPersister entityPersister = event.getPersister(); - for ( int i = 0; i < entityPersister.getPropertyNames().length; ++i ) { - if ( !entityPersister.getPropertyUpdateability()[i] ) { - // Assuming that PostUpdateEvent#getOldState() returns database state of the record before modification. - // Otherwise, we would have to execute SQL query to be sure of @Column(updatable = false) column value. - newDbState[i] = event.getOldState()[i]; + if ( event.getOldState() != null ) { + EntityPersister entityPersister = event.getPersister(); + for ( int i = 0; i < entityPersister.getPropertyNames().length; ++i ) { + if ( !entityPersister.getPropertyUpdateability()[i] ) { + // Assuming that PostUpdateEvent#getOldState() returns database state of the record before modification. + // Otherwise, we would have to execute SQL query to be sure of @Column(updatable = false) column value. + newDbState[i] = event.getOldState()[i]; + } } } return newDbState; diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/onetomany/detached/DetachedTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/onetomany/detached/DetachedTest.java new file mode 100644 index 0000000000..10e7c65af7 --- /dev/null +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/onetomany/detached/DetachedTest.java @@ -0,0 +1,80 @@ +package org.hibernate.envers.test.integration.onetomany.detached; + +import java.util.Arrays; + +import junit.framework.Assert; +import org.junit.Test; + +import org.hibernate.Session; +import org.hibernate.envers.test.BaseEnversFunctionalTestCase; +import org.hibernate.envers.test.Priority; +import org.hibernate.envers.test.entities.StrTestEntity; +import org.hibernate.envers.test.entities.onetomany.detached.ListRefCollEntity; +import org.hibernate.testing.TestForIssue; + +/** + * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) + */ +public class DetachedTest extends BaseEnversFunctionalTestCase { + private Integer parentId = null; + private Integer childId = null; + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { ListRefCollEntity.class, StrTestEntity.class }; + } + + @Test + @Priority(10) + @TestForIssue(jiraKey = "HHH-7543") + public void testUpdatingDetachedEntityWithRelation() { + Session session = getSession(); + + // Revision 1 + session.getTransaction().begin(); + ListRefCollEntity parent = new ListRefCollEntity( 1, "initial data" ); + StrTestEntity child = new StrTestEntity( "data" ); + session.save( child ); + parent.setCollection( Arrays.asList( child ) ); + session.save( parent ); + session.getTransaction().commit(); + + session.close(); + session = getSession(); + + // Revision 2 - updating detached entity + session.getTransaction().begin(); + parent.setData( "modified data" ); + session.update( parent ); + session.getTransaction().commit(); + + session.close(); + + parentId = parent.getId(); + childId = child.getId(); + } + + @Test + public void testRevisionsCounts() { + Assert.assertEquals( Arrays.asList( 1, 2 ), getAuditReader().getRevisions( ListRefCollEntity.class, parentId ) ); + Assert.assertEquals( Arrays.asList( 1 ), getAuditReader().getRevisions( StrTestEntity.class, childId ) ); + } + + @Test + public void testHistoryOfParent() { + ListRefCollEntity parent = new ListRefCollEntity( parentId, "initial data" ); + parent.setCollection( Arrays.asList( new StrTestEntity( "data", childId ) ) ); + + ListRefCollEntity ver1 = getAuditReader().find( ListRefCollEntity.class, parentId, 1 ); + + Assert.assertEquals( parent, ver1 ); + Assert.assertEquals( parent.getCollection(), ver1.getCollection() ); + + parent.setData( "modified data" ); + + ListRefCollEntity ver2 = getAuditReader().find( ListRefCollEntity.class, parentId, 2 ); + + Assert.assertEquals( parent, ver2 ); + Assert.assertEquals( parent.getCollection(), ver2.getCollection() ); + } +} \ No newline at end of file From 63a2f0d7dc22b7a34e7aaf7e9e7516bb235b4095 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Fri, 24 Aug 2012 20:32:45 -0500 Subject: [PATCH 05/38] HHH-7387 - Integrate Draft 6 of the JPA 2.1 spec : CDI via reflection --- .../jpa/BeanManagerListenerFactory.java | 4 + .../jpa/event/spi/JpaIntegrator.java | 43 +++++- .../jpa/test/cdi/NoCdiAvailableTest.java | 138 ++++++++++++++++++ .../test/cdi/NoCdiAvailableTestDelegate.java | 49 +++++++ 4 files changed, 227 insertions(+), 7 deletions(-) create mode 100644 hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTest.java create mode 100644 hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTestDelegate.java diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/BeanManagerListenerFactory.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/BeanManagerListenerFactory.java index 2e55804b10..5598e8ea05 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/BeanManagerListenerFactory.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/BeanManagerListenerFactory.java @@ -42,6 +42,10 @@ public class BeanManagerListenerFactory implements ListenerFactory { private final BeanManager beanManager; private final Map listeners = new ConcurrentHashMap(); + public static BeanManagerListenerFactory fromBeanManagerReference(Object beanManagerReference) { + return new BeanManagerListenerFactory( ( BeanManager ) beanManagerReference ); + } + public BeanManagerListenerFactory(BeanManager beanManager) { this.beanManager = beanManager; } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/spi/JpaIntegrator.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/spi/JpaIntegrator.java index f2ca0f4fac..0c05b5b9fb 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/spi/JpaIntegrator.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/spi/JpaIntegrator.java @@ -23,7 +23,8 @@ */ package org.hibernate.jpa.event.spi; -import javax.enterprise.inject.spi.BeanManager; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.Iterator; import java.util.Map; @@ -187,10 +188,10 @@ public class JpaIntegrator implements Integrator { // handle JPA "entity listener classes"... this.callbackRegistry = new CallbackRegistryImpl(); - final BeanManager beanManager = (BeanManager) configuration.getProperties().get( AvailableSettings.CDI_BEAN_MANAGER ); - this.jpaListenerFactory = beanManager == null + final Object beanManagerRef = configuration.getProperties().get( AvailableSettings.CDI_BEAN_MANAGER ); + this.jpaListenerFactory = beanManagerRef == null ? new StandardListenerFactory() - : new BeanManagerListenerFactory( beanManager ); + : buildBeanManagerListenerFactory( beanManagerRef ); this.callbackProcessor = new LegacyCallbackProcessor( jpaListenerFactory, configuration.getReflectionManager() ); Iterator classes = configuration.getClassMappings(); @@ -213,6 +214,34 @@ public class JpaIntegrator implements Integrator { } } + private ListenerFactory buildBeanManagerListenerFactory(Object beanManagerRef) { + try { + // specifically using our classloader here... + final Class beanManagerListenerFactoryClass = getClass().getClassLoader() + .loadClass( "org.hibernate.jpa.event.internal.jpa.BeanManagerListenerFactory" ); + final Method beanManagerListenerFactoryBuilderMethod = beanManagerListenerFactoryClass.getMethod( + "fromBeanManagerReference", + Object.class + ); + + try { + return (ListenerFactory) beanManagerListenerFactoryBuilderMethod.invoke( null, beanManagerRef ); + } + catch (InvocationTargetException e) { + throw e.getTargetException(); + } + } + catch (ReflectiveOperationException e) { + throw new HibernateException( "Could not access BeanManagerListenerFactory class to handle CDI extensions", e ); + } + catch (RuntimeException e) { + throw e; + } + catch (Throwable e) { + throw new HibernateException( "Problem calling BeanManagerListenerFactory class to handle CDI extensions", e ); + } + } + @Override public void integrate( MetadataImplementor metadata, @@ -288,10 +317,10 @@ public class JpaIntegrator implements Integrator { // handle JPA "entity listener classes"... this.callbackRegistry = new CallbackRegistryImpl(); - final BeanManager beanManager = (BeanManager) sessionFactory.getProperties().get( AvailableSettings.CDI_BEAN_MANAGER ); - this.jpaListenerFactory = beanManager == null + final Object beanManagerRef = sessionFactory.getProperties().get( AvailableSettings.CDI_BEAN_MANAGER ); + this.jpaListenerFactory = beanManagerRef == null ? new StandardListenerFactory() - : new BeanManagerListenerFactory( beanManager ); + : buildBeanManagerListenerFactory( beanManagerRef ); this.callbackProcessor = new CallbackProcessorImpl( jpaListenerFactory, metadata, serviceRegistry ); for ( EntityBinding binding : metadata.getEntityBindings() ) { diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTest.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTest.java new file mode 100644 index 0000000000..48b4cb9ddb --- /dev/null +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTest.java @@ -0,0 +1,138 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.jpa.test.cdi; + +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URL; + +import org.hibernate.bytecode.spi.ByteCodeHelper; + +import org.junit.Rule; +import org.junit.Test; + +import org.hibernate.testing.junit4.BaseUnitTestCase; +import org.hibernate.testing.junit4.ClassLoadingIsolater; + +import static org.junit.Assert.fail; + +/** + * Test JPA bootstrapping when CDI is not available for classloading. + * + * @author Steve Ebersole + */ +public class NoCdiAvailableTest extends BaseUnitTestCase { + public static final String[] EXCLUDED_PACKAGES = new String[] { + "javax.enterprise.inject.", + "javax.enterprise.context." + }; + + private static class CdiClassLoadException extends RuntimeException { + private CdiClassLoadException(String message) { + super( message ); + } + } + + @Rule public ClassLoadingIsolater isolater = new ClassLoadingIsolater( + new ClassLoadingIsolater.IsolatedClassLoaderProvider() { + + @Override + public ClassLoader buildIsolatedClassLoader() { + return new ClassLoader(NoCdiAvailableTest.class.getClassLoader()) { + @Override + public Class loadClass(String name) throws ClassNotFoundException { + for ( String excludedPackage : EXCLUDED_PACKAGES ) { + if ( name.startsWith( excludedPackage ) ) { + throw new CdiClassLoadException( "CDI classes [" + name + "] excluded from load" ); + } + } + + Class c = findLoadedClass( name ); + if ( c != null ) { + return c; + } + + final String resourceName = name.replace( '.', '/' ) + ".class"; + final URL resource = getResource( resourceName ); + if ( resource == null ) { + throw new ClassNotFoundException( name + " not found" ); + } + if ( !"file".equals( resource.getProtocol() ) ) { + return getParent().loadClass( name ); + } + + InputStream is = this.getResourceAsStream( name.replace( '.', '/' ) + ".class" ); + if ( is == null ) { + throw new ClassNotFoundException( name + " not found" ); + } + + try { + byte[] bytecode = ByteCodeHelper.readByteCode( is ); + return defineClass( name, bytecode, 0, bytecode.length ); + } + catch( Throwable t ) { + throw new ClassNotFoundException( "Error reading class file for " + name, t ); + } + } + }; + } + + @Override + public void releaseIsolatedClassLoader(ClassLoader isolatedClassLoader) { + // nothing to do + } + } + ); + + @Test + public void testJpaBootstrapWithoutCdiAvailable() throws Exception { + Class delegateClass = Thread.currentThread().getContextClassLoader().loadClass( + "org.hibernate.jpa.test.cdi.NoCdiAvailableTestDelegate" + ); + Method mainMethod = delegateClass.getMethod( "passingNoBeanManager" ); + mainMethod.invoke( null ); + } + + @Test + public void testJpaBootstrapWithoutCdiAvailablePassingCdi() throws Throwable { + Class delegateClass = Thread.currentThread().getContextClassLoader().loadClass( + "org.hibernate.jpa.test.cdi.NoCdiAvailableTestDelegate" + ); + Method mainMethod = delegateClass.getMethod( "passingBeanManager" ); + try { + mainMethod.invoke( null ); + fail( "Expecting failure from missing CDI classes" ); + } + catch (InvocationTargetException e) { + try { + throw e.getTargetException(); + } + catch (CdiClassLoadException expected) { + } +// catch (ClassCastException expectedAlt) { +// } + } + } +} diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTestDelegate.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTestDelegate.java new file mode 100644 index 0000000000..36fc59a044 --- /dev/null +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTestDelegate.java @@ -0,0 +1,49 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.jpa.test.cdi; + +import java.util.Collections; + +import org.hibernate.jpa.AvailableSettings; +import org.hibernate.jpa.HibernatePersistenceProvider; +import org.hibernate.jpa.test.PersistenceUnitInfoAdapter; + +/** + * @author Steve Ebersole + */ +public class NoCdiAvailableTestDelegate { + public static void passingNoBeanManager() { + new HibernatePersistenceProvider().createContainerEntityManagerFactory( + new PersistenceUnitInfoAdapter(), + Collections.emptyMap() + ); + } + + public static void passingBeanManager() { + new HibernatePersistenceProvider().createContainerEntityManagerFactory( + new PersistenceUnitInfoAdapter(), + Collections.singletonMap( AvailableSettings.CDI_BEAN_MANAGER, new Object() ) + ); + } +} From 110c3a4b92b669ac439d0b4266f06b1043dcaccf Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Fri, 24 Aug 2012 20:39:22 -0500 Subject: [PATCH 06/38] HHH-7550 - Fix UP-TO-DATE checking for APT-based tasks --- build.gradle | 5 ++++- hibernate-entitymanager/hibernate-entitymanager.gradle | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 22aa62c4d2..3b580e2bd9 100644 --- a/build.gradle +++ b/build.gradle @@ -122,7 +122,6 @@ subprojects { subProject -> testCompile files( toolsJar ) } } - ext.aptDumpDir = subProject.file( "${buildDir}/tmp/apt" ) sourceSets.main { compileClasspath += configurations.provided @@ -135,6 +134,7 @@ subprojects { subProject -> } task generateMainLoggingClasses(type: Compile) { + ext.aptDumpDir = subProject.file( "${buildDir}/tmp/apt/logging" ) classpath = compileJava.classpath + configurations.jbossLoggingTool source = sourceSets.main.originalJavaSrcDirs destinationDir = aptDumpDir @@ -157,6 +157,9 @@ subprojects { subProject -> // source = sourceSets.main.originalJavaSrcDirs sourceSets.main.generatedLoggingSrcDir.mkdirs() } + doLast { + aptDumpDir.delete() + } } // for the time being eat the annoying output from running the annotation processors diff --git a/hibernate-entitymanager/hibernate-entitymanager.gradle b/hibernate-entitymanager/hibernate-entitymanager.gradle index fb219fe5a3..617ce7a0d3 100644 --- a/hibernate-entitymanager/hibernate-entitymanager.gradle +++ b/hibernate-entitymanager/hibernate-entitymanager.gradle @@ -24,7 +24,6 @@ dependencies { //////////////////////////////////////////////////////////////////////////////////////////////////////// // JPA model-gen set up //////////////////////////////////////////////////////////////////////////////////////////////////////// -aptDumpDir = file( "${buildDir}/tmp/apt" ) sourceSets.test { originalJavaSrcDirs = java.srcDirs @@ -32,6 +31,7 @@ sourceSets.test { java.srcDir generatedJpaMetamodelSrcDir } task generateTestJpaMetamodelClasses(type: Compile) { + ext.aptDumpDir = file( "${buildDir}/tmp/apt/jpamodelgen" ) classpath = compileTestJava.classpath + configurations.hibernateJpaModelGenTool source = sourceSets.test.originalJavaSrcDirs destinationDir = aptDumpDir @@ -46,6 +46,9 @@ task generateTestJpaMetamodelClasses(type: Compile) { doFirst { sourceSets.test.generatedJpaMetamodelSrcDir.mkdirs() } + doLast { + aptDumpDir.delete() + } } // for the time being eat the annoying output from running the annotation processors generateTestJpaMetamodelClasses.logging.captureStandardError(LogLevel.INFO) From d52a20a6933bbcc344839c0b0c8cb91fd2eb491f Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 27 Aug 2012 15:18:21 -0500 Subject: [PATCH 07/38] HHH-7552 - New StrategySelectorService : initial work --- .../internal/TransactionFactoryInitiator.java | 86 +--------- .../BootstrapServiceRegistryBuilder.java | 28 ++- .../BootstrapServiceRegistryImpl.java | 43 ++++- .../internal/StrategySelectorBuilder.java | 105 ++++++++++++ .../internal/StrategySelectorImpl.java | 161 ++++++++++++++++++ .../service/selector/package-info.java | 1 + .../spi/StrategySelectionException.java | 39 +++++ .../selector/spi/StrategySelector.java | 98 +++++++++++ .../embeddables/EmbeddableIntegratorTest.java | 27 +-- 9 files changed, 481 insertions(+), 107 deletions(-) create mode 100644 hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorBuilder.java create mode 100644 hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorImpl.java create mode 100644 hibernate-core/src/main/java/org/hibernate/service/selector/package-info.java create mode 100644 hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelectionException.java create mode 100644 hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelector.java diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionFactoryInitiator.java index b38fbf2564..2f153e75f0 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionFactoryInitiator.java @@ -27,16 +27,12 @@ import java.util.Map; import org.jboss.logging.Logger; -import org.hibernate.HibernateException; -import org.hibernate.cfg.Environment; +import org.hibernate.cfg.AvailableSettings; import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory; -import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; -import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory; import org.hibernate.engine.transaction.spi.TransactionFactory; import org.hibernate.engine.transaction.spi.TransactionImplementor; import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.classloading.spi.ClassLoadingException; +import org.hibernate.service.selector.spi.StrategySelector; import org.hibernate.service.spi.BasicServiceInitiator; import org.hibernate.service.spi.ServiceRegistryImplementor; @@ -64,86 +60,14 @@ public class TransactionFactoryInitiator @Override @SuppressWarnings( {"unchecked"}) public TransactionFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) { - final Object strategy = configurationValues.get( Environment.TRANSACTION_STRATEGY ); + final Object strategy = configurationValues.get( AvailableSettings.TRANSACTION_STRATEGY ); + if ( strategy == null ) { LOG.usingDefaultTransactionStrategy(); return new JdbcTransactionFactory(); } - if ( TransactionFactory.class.isInstance( strategy ) ) { - return (TransactionFactory) strategy; - } - - Class transactionFactoryClass; - if ( Class.class.isInstance( strategy ) ) { - final Class theClass = (Class) strategy; - LOG.transactionStrategy( theClass.getName() ); - try { - transactionFactoryClass = (Class) theClass; - } - catch (ClassCastException e) { - throw new ClassLoadingException( - String.format( - "TransactionFactory implementation class [%s] did not implement TransactionFactory interface", - theClass.getName() - ) - ); - } - } - else { - final String strategyClassName = mapName( strategy.toString() ); - LOG.transactionStrategy( strategyClassName ); - - try { - transactionFactoryClass = registry.getService( ClassLoaderService.class ).classForName( strategyClassName ); - } - catch (ClassCastException e) { - throw new ClassLoadingException( - String.format( - "TransactionFactory implementation class [%s] did not implement TransactionFactory interface", - strategyClassName - ) - ); - } - } - - try { - return transactionFactoryClass.newInstance(); - } - catch ( Exception e ) { - throw new HibernateException( "Unable to instantiate specified TransactionFactory class [" + transactionFactoryClass.getName() + "]", e ); - } - } - - private String mapName(String name) { - // check legacy names ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if ( "org.hibernate.transaction.JDBCTransactionFactory".equals( name ) ) { - return JdbcTransactionFactory.class.getName(); - } - - if ( "org.hibernate.transaction.JTATransactionFactory".equals( name ) ) { - return JtaTransactionFactory.class.getName(); - } - - if ( "org.hibernate.transaction.CMTTransactionFactory".equals( name ) ) { - return CMTTransactionFactory.class.getName(); - } - - // check short names ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if ( JdbcTransactionFactory.SHORT_NAME.endsWith( name ) ) { - return JdbcTransactionFactory.class.getName(); - } - - if ( JtaTransactionFactory.SHORT_NAME.equals( name ) ) { - return JtaTransactionFactory.class.getName(); - } - - if ( CMTTransactionFactory.SHORT_NAME.equals( name ) ) { - return CMTTransactionFactory.class.getName(); - } - - - return name; + return registry.getService( StrategySelector.class ).resolveStrategy( TransactionFactory.class, strategy ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistryBuilder.java index 165c9b436a..6c1107bb6b 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistryBuilder.java @@ -29,6 +29,8 @@ import org.hibernate.integrator.internal.IntegratorServiceImpl; import org.hibernate.integrator.spi.Integrator; import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl; import org.hibernate.service.internal.BootstrapServiceRegistryImpl; +import org.hibernate.service.selector.internal.StrategySelectorBuilder; +import org.hibernate.service.selector.internal.StrategySelectorImpl; /** * Builder for bootstrap {@link ServiceRegistry} instances. @@ -45,6 +47,8 @@ public class BootstrapServiceRegistryBuilder { private ClassLoader hibernateClassLoader; private ClassLoader environmentClassLoader; + private StrategySelectorBuilder strategySelectorBuilder = new StrategySelectorBuilder(); + /** * Add an {@link Integrator} to be applied to the bootstrap registry. * @@ -104,6 +108,23 @@ public class BootstrapServiceRegistryBuilder { return this; } + /** + * Applies a named strategy implementation to the bootstrap registry + * + * @param strategy The strategy + * @param name The registered name + * @param implementation The strategy implementation Class + * + * @return {@code this}, for method chaining + * + * @see org.hibernate.service.selector.spi.StrategySelector#registerStrategyImplementor(Class, String, Class) + */ + @SuppressWarnings( {"UnusedDeclaration"}) + public BootstrapServiceRegistryBuilder withStrategySelector(Class strategy, String name, Class implementation) { + this.strategySelectorBuilder.addCustomRegistration( strategy, name, implementation ); + return this; + } + /** * Build the bootstrap registry. * @@ -122,6 +143,11 @@ public class BootstrapServiceRegistryBuilder { classLoaderService ); - return new BootstrapServiceRegistryImpl( classLoaderService, integratorService ); + + return new BootstrapServiceRegistryImpl( + classLoaderService, + strategySelectorBuilder.buildSelector( classLoaderService ), + integratorService + ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/BootstrapServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/service/internal/BootstrapServiceRegistryImpl.java index 5a33aeb1c6..3659ce8b71 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/BootstrapServiceRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/BootstrapServiceRegistryImpl.java @@ -33,6 +33,8 @@ import org.hibernate.service.Service; import org.hibernate.service.ServiceRegistry; import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl; import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.service.selector.internal.StrategySelectorImpl; +import org.hibernate.service.selector.spi.StrategySelector; import org.hibernate.service.spi.ServiceBinding; import org.hibernate.service.spi.ServiceException; import org.hibernate.service.spi.ServiceInitiator; @@ -51,6 +53,7 @@ public class BootstrapServiceRegistryImpl private static final LinkedHashSet NO_INTEGRATORS = new LinkedHashSet(); private final ServiceBinding classLoaderServiceBinding; + private final ServiceBinding strategySelectorBinding; private final ServiceBinding integratorServiceBinding; public BootstrapServiceRegistryImpl() { @@ -59,6 +62,30 @@ public class BootstrapServiceRegistryImpl public BootstrapServiceRegistryImpl( ClassLoaderService classLoaderService, + LinkedHashSet providedIntegrators) { + this.classLoaderServiceBinding = new ServiceBinding( + this, + ClassLoaderService.class, + classLoaderService + ); + + final StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService ); + this.strategySelectorBinding = new ServiceBinding( + this, + StrategySelector.class, + strategySelector + ); + + this.integratorServiceBinding = new ServiceBinding( + this, + IntegratorService.class, + new IntegratorServiceImpl( providedIntegrators, classLoaderService ) + ); + } + + public BootstrapServiceRegistryImpl( + ClassLoaderService classLoaderService, + StrategySelector strategySelector, IntegratorService integratorService) { this.classLoaderServiceBinding = new ServiceBinding( this, @@ -66,6 +93,12 @@ public class BootstrapServiceRegistryImpl classLoaderService ); + this.strategySelectorBinding = new ServiceBinding( + this, + StrategySelector.class, + strategySelector + ); + this.integratorServiceBinding = new ServiceBinding( this, IntegratorService.class, @@ -74,13 +107,6 @@ public class BootstrapServiceRegistryImpl } - public BootstrapServiceRegistryImpl( - ClassLoaderService classLoaderService, - LinkedHashSet providedIntegrators) { - this( classLoaderService, new IntegratorServiceImpl( providedIntegrators, classLoaderService ) ); - } - - @Override public R getService(Class serviceRole) { @@ -94,6 +120,9 @@ public class BootstrapServiceRegistryImpl if ( ClassLoaderService.class.equals( serviceRole ) ) { return (ServiceBinding) classLoaderServiceBinding; } + else if ( StrategySelector.class.equals( serviceRole) ) { + return (ServiceBinding) strategySelectorBinding; + } else if ( IntegratorService.class.equals( serviceRole ) ) { return (ServiceBinding) integratorServiceBinding; } diff --git a/hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorBuilder.java b/hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorBuilder.java new file mode 100644 index 0000000000..54002abb84 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorBuilder.java @@ -0,0 +1,105 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.service.selector.internal; + +import java.util.ArrayList; +import java.util.List; + +import org.jboss.logging.Logger; + +import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory; +import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; +import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory; +import org.hibernate.engine.transaction.spi.TransactionFactory; +import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl; +import org.hibernate.service.selector.spi.StrategySelectionException; +import org.hibernate.service.selector.spi.StrategySelector; + +/** + * @author Steve Ebersole + */ +public class StrategySelectorBuilder { + private static final Logger log = Logger.getLogger( StrategySelectorBuilder.class ); + + private static class CustomRegistration { + private final Class strategy; + private final String name; + private final Class implementation; + + private CustomRegistration(Class strategy, String name, Class implementation) { + this.strategy = strategy; + this.name = name; + this.implementation = implementation; + } + + public void registerWith(StrategySelectorImpl strategySelector) { + strategySelector.registerStrategyImplementor( strategy, name, implementation ); + } + } + + private final List customRegistrations = new ArrayList(); + + @SuppressWarnings("unchecked") + public void addCustomRegistration(Class strategy, String name, Class implementation) { + if ( !strategy.isInterface() ) { + // not good form... + log.debug( "Registering non-interface strategy implementation : " + strategy.getName() ); + } + + if ( ! strategy.isAssignableFrom( implementation ) ) { + throw new StrategySelectionException( + "Implementation class [" + implementation.getName() + "] does not implement strategy interface [" + + strategy.getName() + "]" + ); + } + customRegistrations.add( new CustomRegistration( strategy, name, implementation ) ); + } + + public StrategySelector buildSelector(ClassLoaderServiceImpl classLoaderService) { + StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService ); + + // build the baseline... + addTransactionFactories( strategySelector ); + + // todo : apply auto-discovered registrations + + // apply customizations + for ( CustomRegistration customRegistration : customRegistrations ) { + customRegistration.registerWith( strategySelector ); + } + + return strategySelector; + } + + private void addTransactionFactories(StrategySelectorImpl strategySelector) { + strategySelector.registerStrategyImplementor( TransactionFactory.class, JdbcTransactionFactory.SHORT_NAME, JdbcTransactionFactory.class ); + strategySelector.registerStrategyImplementor( TransactionFactory.class, "org.hibernate.transaction.JDBCTransactionFactory", JdbcTransactionFactory.class ); + + strategySelector.registerStrategyImplementor( TransactionFactory.class, JtaTransactionFactory.SHORT_NAME, JtaTransactionFactory.class ); + strategySelector.registerStrategyImplementor( TransactionFactory.class, "org.hibernate.transaction.JTATransactionFactory", JtaTransactionFactory.class ); + + strategySelector.registerStrategyImplementor( TransactionFactory.class, CMTTransactionFactory.SHORT_NAME, CMTTransactionFactory.class ); + strategySelector.registerStrategyImplementor( TransactionFactory.class, "org.hibernate.transaction.CMTTransactionFactory", CMTTransactionFactory.class ); + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorImpl.java b/hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorImpl.java new file mode 100644 index 0000000000..42e2d45e01 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorImpl.java @@ -0,0 +1,161 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.service.selector.internal; + +import java.util.Iterator; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.jboss.logging.Logger; + +import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.service.classloading.spi.ClassLoadingException; +import org.hibernate.service.selector.spi.StrategySelectionException; +import org.hibernate.service.selector.spi.StrategySelector; + +/** + * @author Steve Ebersole + */ +public class StrategySelectorImpl implements StrategySelector { + private static final Logger log = Logger.getLogger( StrategySelectorImpl.class ); + + private final Map> namedStrategyImplementorByStrategyMap + = new ConcurrentHashMap>(); + + private final ClassLoaderService classLoaderService; + + public StrategySelectorImpl(ClassLoaderService classLoaderService) { + this.classLoaderService = classLoaderService; + } + + @Override + public void registerStrategyImplementor(Class strategy, String name, Class implementation) { + Map namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy ); + if ( namedStrategyImplementorMap == null ) { + namedStrategyImplementorMap = new ConcurrentHashMap(); + namedStrategyImplementorByStrategyMap.put( strategy, namedStrategyImplementorMap ); + } + + Class old = namedStrategyImplementorMap.put( name, implementation ); + if ( old == null ) { + log.trace( + String.format( + "Registering named strategy selector [%s] : [%s] -> [%s]", + strategy.getName(), + name, + implementation.getName() + ) + ); + } + else { + log.debug( + String.format( + "Registering named strategy selector [%s] : [%s] -> [%s] (replacing [%s])", + strategy.getName(), + name, + implementation.getName(), + old.getName() + ) + ); + } + } + + @Override + public void unRegisterStrategyImplementor(Class strategy, Class implementation) { + Map namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy ); + if ( namedStrategyImplementorMap == null ) { + log.debug( "Named strategy map did not exist on call to un-register" ); + return; + } + + final Iterator itr = namedStrategyImplementorMap.values().iterator(); + while ( itr.hasNext() ) { + final Class registered = (Class) itr.next(); + if ( registered.equals( implementation ) ) { + itr.remove(); + } + } + + // try tp clean up after ourselves... + if ( namedStrategyImplementorMap.isEmpty() ) { + namedStrategyImplementorByStrategyMap.remove( strategy ); + } + } + + @Override + @SuppressWarnings("unchecked") + public Class selectStrategyImplementor(Class strategy, String name) { + Map namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy ); + if ( namedStrategyImplementorMap != null ) { + final Class registered = namedStrategyImplementorMap.get( name ); + if ( registered != null ) { + return (Class) registered; + } + } + + try { + return classLoaderService.classForName( name ); + } + catch (ClassLoadingException e) { + throw new StrategySelectionException( + "Unable to resolve name [" + name + "] as strategy [" + strategy.getName() + "]" + ); + } + } + + @Override + public T resolveStrategy(Class strategy, Object strategyReference) { + return resolveDefaultableStrategy( strategy, strategyReference, null ); + } + + @Override + @SuppressWarnings("unchecked") + public T resolveDefaultableStrategy(Class strategy, Object strategyReference, T defaultValue) { + if ( strategyReference == null ) { + return defaultValue; + } + + if ( strategy.isInstance( strategyReference ) ) { + return strategy.cast( strategyReference ); + } + + final Class implementationClass; + if ( Class.class.isInstance( strategyReference ) ) { + implementationClass = (Class) strategyReference; + } + else { + implementationClass = selectStrategyImplementor( strategy, strategyReference.toString() ); + } + + try { + return implementationClass.newInstance(); + } + catch (Exception e) { + throw new StrategySelectionException( + String.format( "Could not instantiate named strategy class [%s]", implementationClass.getName() ), + e + ); + } + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/service/selector/package-info.java b/hibernate-core/src/main/java/org/hibernate/service/selector/package-info.java new file mode 100644 index 0000000000..885cc72a2e --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/service/selector/package-info.java @@ -0,0 +1 @@ +package org.hibernate.service.selector; \ No newline at end of file diff --git a/hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelectionException.java b/hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelectionException.java new file mode 100644 index 0000000000..5caf1e2804 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelectionException.java @@ -0,0 +1,39 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.service.selector.spi; + +import org.hibernate.HibernateException; + +/** + * @author Steve Ebersole + */ +public class StrategySelectionException extends HibernateException { + public StrategySelectionException(String message) { + super( message ); + } + + public StrategySelectionException(String message, Throwable root) { + super( message, root ); + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelector.java b/hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelector.java new file mode 100644 index 0000000000..222c4dc047 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelector.java @@ -0,0 +1,98 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.service.selector.spi; + +import org.hibernate.service.Service; + +/** + * Service which acts as a registry for named strategy implementations. + * + * @author Steve Ebersole + */ +public interface StrategySelector extends Service { + /** + * Registers a named implementor of a particular strategy contract. + * + * @param strategy The strategy contract. + * @param name The registration name + * @param implementation The implementation Class + */ + public void registerStrategyImplementor(Class strategy, String name, Class implementation); + + /** + * Un-registers a named implementor of a particular strategy contract. Un-registers all named registrations + * for the given strategy contract naming the given class. + * + * @param strategy The strategy contract. + * @param implementation The implementation Class + */ + public void unRegisterStrategyImplementor(Class strategy, Class implementation); + + /** + * Locate the named strategy implementation. + * + * @param strategy The type of strategy to be resolved. + * @param name The name of the strategy to locate; might be either a registered name or the implementation FQN. + * + * @return The named strategy implementation class. + */ + public Class selectStrategyImplementor(Class strategy, String name); + + /** + * Resolve strategy instances. See discussion on {@link #resolveDefaultableStrategy}. + * Only difference is that here, the implied default value is {@code null}. + * + * @param strategy The type (interface) of the strategy to be resolved. + * @param strategyReference The reference to the strategy for which we need to resolve an instance. + * + * @return The strategy instance + */ + public T resolveStrategy(Class strategy, Object strategyReference); + + /** + * Resolve strategy instances. The incoming reference might be:
    + *
  • + * {@code null} - in which case defaultValue is returned. + *
  • + *
  • + * An actual instance of the strategy type - it is returned, as is + *
  • + *
  • + * A reference to the implementation {@link Class} - an instance is created by calling + * {@link Class#newInstance()} (aka, the class's no-arg ctor). + *
  • + *
  • + * The name of the implementation class - First the implementation's {@link Class} reference + * is resolved, and then an instance is created by calling {@link Class#newInstance()} + *
  • + *
+ * + * @param strategy The type (interface) of the strategy to be resolved. + * @param strategyReference The reference to the strategy for which we need to resolve an instance. + * @param defaultValue THe default value to use if strategyReference is null + * + * @return The strategy instance + */ + public T resolveDefaultableStrategy(Class strategy, Object strategyReference, T defaultValue); +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java index 8b71febc67..5a0688b67c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java @@ -23,29 +23,26 @@ */ package org.hibernate.test.annotations.embeddables; -import static org.junit.Assert.assertEquals; - import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; -import java.util.LinkedHashSet; import java.util.List; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.exception.GenericJDBCException; -import org.hibernate.integrator.internal.IntegratorServiceImpl; -import org.hibernate.integrator.spi.Integrator; -import org.hibernate.integrator.spi.IntegratorService; +import org.hibernate.service.BootstrapServiceRegistryBuilder; import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl; -import org.hibernate.service.classloading.spi.ClassLoaderService; import org.hibernate.service.internal.BootstrapServiceRegistryImpl; -import org.hibernate.testing.junit4.BaseUnitTestCase; + import org.junit.Test; +import org.hibernate.testing.junit4.BaseUnitTestCase; + +import static org.junit.Assert.assertEquals; + /** * @author Chris Pheby */ @@ -81,15 +78,9 @@ public class EmbeddableIntegratorTest extends BaseUnitTestCase { @Test public void testWithIntegrator() { - - LinkedHashSet providedIntegrators = new LinkedHashSet(); - providedIntegrators.add(new InvestorIntegrator()); - ClassLoaderService classLoaderService = new ClassLoaderServiceImpl(); - IntegratorService integratorService = new IntegratorServiceImpl(providedIntegrators, classLoaderService); - - ServiceRegistry reg = new ServiceRegistryBuilder(new BootstrapServiceRegistryImpl( - classLoaderService, - integratorService)).buildServiceRegistry(); + ServiceRegistry reg = new ServiceRegistryBuilder( + new BootstrapServiceRegistryBuilder().with( new InvestorIntegrator() ).build() + ).buildServiceRegistry(); SessionFactory sf = new Configuration() .addAnnotatedClass( Investor.class ) From 4ad49a02c9058831e2652e84de722220335b2780 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Tue, 28 Aug 2012 14:12:14 -0500 Subject: [PATCH 08/38] HHH-7556 - Clean up packages --- changelog.txt | 2 +- .../devguide/en-US/Database_Access.xml | 16 +- .../chapters/multitenancy/Multi_Tenancy.xml | 10 +- .../en-US/chapters/services/Services.xml | 102 ++++---- .../chapters/transactions/Transactions.xml | 4 +- .../internal/C3P0ConnectionProvider.java | 7 +- .../test/c3p0/C3P0ConnectionProviderTest.java | 2 +- .../java/org/hibernate/SessionFactory.java | 2 +- .../registry/BootstrapServiceRegistry.java | 35 +++ .../BootstrapServiceRegistryBuilder.java | 152 ++++++++++++ .../registry/StandardServiceInitiator.java} | 6 +- .../StandardServiceRegistryBuilder.java | 224 ++++++++++++++++++ .../internal/ClassLoaderServiceImpl.java | 6 +- .../classloading/spi/ClassLoaderService.java | 2 +- .../spi/ClassLoadingException.java | 2 +- .../BootstrapServiceRegistryImpl.java | 19 +- .../internal/StandardServiceRegistryImpl.java | 12 +- .../internal/StrategySelectorBuilder.java | 8 +- .../internal/StrategySelectorImpl.java | 10 +- .../boot/registry/selector/package-info.java | 1 + .../spi/StrategySelectionException.java | 2 +- .../selector/spi/StrategySelector.java | 2 +- .../internal/RegionFactoryInitiator.java | 6 +- .../org/hibernate/cfg/AvailableSettings.java | 22 +- .../java/org/hibernate/cfg/Configuration.java | 8 +- .../java/org/hibernate/cfg/Environment.java | 2 +- .../main/java/org/hibernate/cfg/Settings.java | 2 +- .../org/hibernate/cfg/SettingsFactory.java | 8 +- .../BeanValidationIntegrator.java | 2 +- .../context/internal/JTASessionContext.java | 2 +- .../internal/ConfigurationServiceImpl.java | 8 +- .../ConfigurationServiceInitiator.java | 8 +- .../config/spi/ConfigurationService.java | 2 +- .../batch/internal/BatchBuilderInitiator.java | 6 +- .../internal/ConnectionProviderInitiator.java | 10 +- .../DatasourceConnectionProviderImpl.java | 8 +- .../DriverManagerConnectionProviderImpl.java | 8 +- ...ultiTenantConnectionProviderInitiator.java | 16 +- .../UserSuppliedConnectionProviderImpl.java | 4 +- ...asedMultiTenantConnectionProviderImpl.java | 2 +- ...AbstractMultiTenantConnectionProvider.java | 2 +- .../connections/spi/ConnectionProvider.java | 2 +- ...asedMultiTenantConnectionProviderImpl.java | 6 +- .../spi/MultiTenantConnectionProvider.java | 2 +- .../internal/RefCursorSupportInitiator.java | 8 +- .../internal/StandardRefCursorSupport.java | 4 +- .../jdbc/cursor/spi/RefCursorSupport.java | 2 +- .../internal/AbstractDialectResolver.java | 4 +- .../internal/BasicDialectResolver.java | 2 +- .../dialect/internal/DialectFactoryImpl.java | 10 +- .../internal/DialectFactoryInitiator.java | 8 +- .../internal/DialectResolverInitiator.java | 10 +- .../dialect/internal/DialectResolverSet.java | 4 +- .../internal/StandardDialectResolver.java | 2 +- .../jdbc/dialect/spi/DialectFactory.java | 2 +- .../jdbc/dialect/spi/DialectResolver.java | 2 +- .../jdbc/internal/JdbcServicesImpl.java | 8 +- .../jdbc/internal/JdbcServicesInitiator.java | 4 +- .../engine/jdbc/spi/JdbcConnectionAccess.java | 4 +- .../engine/jdbc/spi/JdbcServices.java | 2 +- .../jndi/JndiException.java | 2 +- .../jndi/JndiNameException.java | 2 +- .../jndi/internal/JndiServiceImpl.java | 8 +- .../jndi/internal/JndiServiceInitiator.java | 8 +- .../jndi/spi/JndiService.java | 2 +- .../engine/spi/SessionFactoryImplementor.java | 2 +- .../internal/TransactionCoordinatorImpl.java | 2 +- .../internal/TransactionFactoryInitiator.java | 6 +- .../internal/jta/JtaTransactionFactory.java | 2 +- .../internal/AbstractJtaPlatform.java | 6 +- .../internal/BitronixJtaPlatform.java | 6 +- .../BorlandEnterpriseServerJtaPlatform.java | 2 +- .../internal/JBossAppServerJtaPlatform.java | 4 +- .../internal/JBossStandAloneJtaPlatform.java | 6 +- .../platform/internal/JOTMJtaPlatform.java | 6 +- .../platform/internal/JOnASJtaPlatform.java | 4 +- .../platform/internal/JRun4JtaPlatform.java | 4 +- .../internal/JtaPlatformInitiator.java | 16 +- .../internal/JtaSynchronizationStrategy.java | 2 +- .../jta/platform/internal/NoJtaPlatform.java | 4 +- .../platform/internal/OC4JJtaPlatform.java | 4 +- .../platform/internal/OrionJtaPlatform.java | 4 +- .../platform/internal/ResinJtaPlatform.java | 4 +- .../platform/internal/SunOneJtaPlatform.java | 4 +- .../SynchronizationRegistryAccess.java | 2 +- ...nRegistryBasedSynchronizationStrategy.java | 2 +- .../internal/TransactionManagerAccess.java | 2 +- ...onManagerBasedSynchronizationStrategy.java | 4 +- .../TransactionManagerLookupBridge.java | 4 +- .../WebSphereExtendedJtaPlatform.java | 2 +- .../internal/WebSphereJtaPlatform.java | 4 +- .../internal/WeblogicJtaPlatform.java | 4 +- .../jta/platform/spi/JtaPlatform.java | 2 +- .../platform/spi/JtaPlatformException.java | 2 +- .../spi/AbstractTransactionImpl.java | 4 +- .../spi/TransactionEnvironment.java | 2 +- ...leIdentifierGeneratorFactoryInitiator.java | 4 +- .../internal/IntegratorServiceImpl.java | 2 +- .../spi/ServiceContributingIntegrator.java | 4 +- .../internal/AbstractSessionImpl.java | 4 +- .../hibernate/internal/CoreMessageLogger.java | 6 +- .../internal/SessionFactoryImpl.java | 14 +- .../internal/SessionFactoryRegistry.java | 6 +- .../internal/StoredProcedureCallImpl.java | 2 +- .../internal/StoredProcedureOutputsImpl.java | 5 +- .../internal/TransactionEnvironmentImpl.java | 2 +- .../hibernate/internal/util/ConfigHelper.java | 2 +- .../internal/util/jndi/JndiHelper.java | 2 +- .../org/hibernate/jmx/HibernateService.java | 4 +- .../hibernate/jmx/HibernateServiceMBean.java | 6 +- .../org/hibernate/jmx/SessionFactoryStub.java | 2 +- .../jmx/internal/DisabledJmxServiceImpl.java | 4 +- .../jmx/internal/JmxServiceImpl.java | 4 +- .../jmx/internal/JmxServiceInitiator.java | 8 +- .../main/java/org/hibernate/jmx/package.html | 14 -- .../{service => }/jmx/spi/JmxService.java | 2 +- .../hibernate/metamodel/MetadataSources.java | 2 +- .../hibernate/metamodel/domain/JavaType.java | 2 +- .../org/hibernate/metamodel/domain/Type.java | 2 +- .../AnnotationBindingContextImpl.java | 2 +- ...AnnotationMetadataSourceProcessorImpl.java | 2 +- .../source/annotations/JandexHelper.java | 2 +- .../annotations/xml/mocker/IndexBuilder.java | 2 +- .../annotations/xml/mocker/MockHelper.java | 2 +- .../metamodel/source/hbm/Helper.java | 4 +- .../source/hbm/HibernateMappingProcessor.java | 4 +- .../internal/IdentifierGeneratorResolver.java | 2 +- .../metamodel/source/internal/JaxbHelper.java | 2 +- .../source/internal/MetadataBuilderImpl.java | 2 +- .../source/internal/MetadataImpl.java | 2 +- .../PersisterClassResolverInitiator.java | 6 +- .../internal/PersisterFactoryInitiator.java | 6 +- .../service/BootstrapServiceRegistry.java | 10 +- .../BootstrapServiceRegistryBuilder.java | 116 ++------- .../org/hibernate/service/ConfigLoader.java | 3 +- .../hibernate/service/ServiceRegistry.java | 4 +- .../service/ServiceRegistryBuilder.java | 184 ++------------ .../service/StandardServiceInitiators.java | 26 +- .../internal/AbstractServiceRegistryImpl.java | 4 +- .../service/internal/JaxbProcessor.java | 2 +- ...sionFactoryServiceRegistryFactoryImpl.java | 2 +- ...actoryServiceRegistryFactoryInitiator.java | 4 +- .../service/selector/package-info.java | 1 - .../stat/internal/StatisticsInitiator.java | 4 +- .../stat/spi/StatisticsImplementor.java | 2 +- .../ImportSqlCommandExtractorInitiator.java | 6 +- .../ManagedProviderConnectionHelper.java | 8 +- .../hibernate/tool/hbm2ddl/SchemaExport.java | 10 +- .../hibernate/tool/hbm2ddl/SchemaUpdate.java | 6 +- .../tool/hbm2ddl/SchemaValidator.java | 6 +- ...iedConnectionProviderConnectionHelper.java | 2 +- .../hibernate/connection/PropertiesTest.java | 2 +- .../hibernate/dialect/TestingDialects.java | 4 +- .../dialect/resolver/DialectFactoryTest.java | 12 +- .../dialect/resolver/DialectResolverTest.java | 6 +- .../binding/AbstractBasicBindingTests.java | 6 +- .../binding/BasicCollectionBindingTests.java | 6 +- .../binding/SimpleValueBindingTests.java | 2 +- .../entity/BaseAnnotationBindingTestCase.java | 5 +- .../entity/IdentifierGeneratorTest.java | 4 +- .../source/annotations/entity/MapsIdTest.java | 4 +- .../global/FetchProfileBinderTest.java | 8 +- .../annotations/global/QueryBinderTest.java | 8 +- .../util/BaseAnnotationIndexTestCase.java | 6 +- .../annotations/util/JandexHelperTest.java | 8 +- .../annotations/xml/OrmXmlParserTests.java | 9 +- .../xml/mocker/AbstractMockerTest.java | 2 +- .../annotations/xml/mocker/XmlHelper.java | 2 +- .../source/internal/MetadataImplTest.java | 15 +- .../SessionFactoryBuilderImplTest.java | 5 +- .../embeddables/EmbeddableIntegratorTest.java | 10 +- .../persister/PersisterClassProviderTest.java | 19 +- .../common/BasicTestingJdbcServiceImpl.java | 2 +- .../test/common/JdbcConnectionAccessImpl.java | 2 +- .../common/TransactionEnvironmentImpl.java | 2 +- .../connections/AggressiveReleaseTest.java | 2 +- .../connections/SuppliedConnectionTest.java | 4 +- .../hibernate/test/events/CallbackTest.java | 2 +- .../test/extendshbm/ExtendsTest.java | 2 +- .../CommandExtractorServiceTest.java | 5 +- .../TestAutoFlushBeforeQueryExecution.java | 3 +- ...TestCollectionInitializingDuringFlush.java | 2 +- .../test/jdbc/proxies/BatchingTest.java | 6 +- .../hibernate/test/jpa/AbstractJPATest.java | 2 +- .../component/EagerKeyManyToOneTest.java | 2 +- .../org/hibernate/test/legacy/FooBarTest.java | 2 +- .../ConfigurationValidationTest.java | 8 +- .../TestingConnectionProvider.java | 4 +- .../schema/SchemaBasedMultiTenancyTest.java | 12 +- .../service/ClassLoaderServiceImplTest.java | 2 +- .../service/ServiceBootstrappingTest.java | 18 +- .../transaction/jdbc/TestExpectedUsage.java | 6 +- .../transaction/jta/BasicDrivingTest.java | 8 +- .../transaction/jta/ManagedDrivingTest.java | 8 +- .../ehcache/AbstractEhcacheRegionFactory.java | 2 +- .../EntityManagerFactoryBuilderImpl.java | 16 +- .../boot/internal/PersistenceXmlParser.java | 4 +- .../internal/jpa/CallbackProcessorImpl.java | 5 +- .../jpa/event/spi/JpaIntegrator.java | 3 +- .../jpa/spi/AbstractEntityManagerImpl.java | 2 +- .../BaseEntityManagerFunctionalTestCase.java | 2 +- .../configuration/AuditConfiguration.java | 2 +- .../envers/event/EnversIntegrator.java | 2 +- .../test/BaseEnversJPAFunctionalTestCase.java | 2 +- .../AbstractEntityManagerTest.java | 4 +- .../tm/HibernateTransactionManagerLookup.java | 2 +- ...bstractEntityCollectionRegionTestCase.java | 2 +- .../AbstractGeneralDataRegionTestCase.java | 11 +- .../InfinispanRegionFactoryTestCase.java | 4 +- .../cache/infinispan/NodeEnvironment.java | 6 +- .../functional/ConcurrentWriteTest.java | 4 +- .../functional/SingleNodeTestCase.java | 4 +- .../bulk/BulkOperationsTestCase.java | 4 +- .../DualNodeConnectionProviderImpl.java | 2 +- .../cluster/DualNodeJtaPlatformImpl.java | 2 +- .../functional/cluster/DualNodeTestCase.java | 2 +- .../query/QueryRegionImplTestCase.java | 7 +- .../TimestampsRegionImplTestCase.java | 7 +- .../tm/JBossStandaloneJtaExampleTest.java | 2 +- .../cache/infinispan/tm/JtaPlatformImpl.java | 2 +- .../infinispan/tm/XaConnectionProvider.java | 2 +- .../infinispan/util/BatchModeJtaPlatform.java | 2 +- .../internal/ProxoolConnectionProvider.java | 2 +- .../testing/ServiceRegistryBuilder.java | 5 +- .../env/ConnectionProviderBuilder.java | 2 +- .../jta/JtaAwareConnectionProviderImpl.java | 7 +- .../testing/jta/TestingJtaPlatformImpl.java | 8 +- .../junit4/BaseCoreFunctionalTestCase.java | 14 +- 228 files changed, 1057 insertions(+), 860 deletions(-) create mode 100644 hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistry.java create mode 100644 hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java rename hibernate-core/src/main/java/org/hibernate/{service/spi/BasicServiceInitiator.java => boot/registry/StandardServiceInitiator.java} (86%) create mode 100644 hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java rename hibernate-core/src/main/java/org/hibernate/{service => boot/registry}/classloading/internal/ClassLoaderServiceImpl.java (97%) rename hibernate-core/src/main/java/org/hibernate/{service => boot/registry}/classloading/spi/ClassLoaderService.java (98%) rename hibernate-core/src/main/java/org/hibernate/{service => boot/registry}/classloading/spi/ClassLoadingException.java (96%) rename hibernate-core/src/main/java/org/hibernate/{service => boot/registry}/internal/BootstrapServiceRegistryImpl.java (86%) rename hibernate-core/src/main/java/org/hibernate/{service => boot/registry}/internal/StandardServiceRegistryImpl.java (85%) rename hibernate-core/src/main/java/org/hibernate/{service => boot/registry}/selector/internal/StrategySelectorBuilder.java (93%) rename hibernate-core/src/main/java/org/hibernate/{service => boot/registry}/selector/internal/StrategySelectorImpl.java (93%) create mode 100644 hibernate-core/src/main/java/org/hibernate/boot/registry/selector/package-info.java rename hibernate-core/src/main/java/org/hibernate/{service => boot/registry}/selector/spi/StrategySelectionException.java (96%) rename hibernate-core/src/main/java/org/hibernate/{service => boot/registry}/selector/spi/StrategySelector.java (98%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/config/internal/ConfigurationServiceImpl.java (93%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/config/internal/ConfigurationServiceInitiator.java (85%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/config/spi/ConfigurationService.java (97%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/connections/internal/ConnectionProviderInitiator.java (96%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/connections/internal/DatasourceConnectionProviderImpl.java (93%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java (96%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java (85%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java (95%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java (98%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java (98%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/connections/spi/ConnectionProvider.java (98%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java (96%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/connections/spi/MultiTenantConnectionProvider.java (98%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/cursor/internal/RefCursorSupportInitiator.java (84%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/cursor/internal/StandardRefCursorSupport.java (98%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/cursor/spi/RefCursorSupport.java (98%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/dialect/internal/AbstractDialectResolver.java (96%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/dialect/internal/BasicDialectResolver.java (98%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/dialect/internal/DialectFactoryImpl.java (92%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/dialect/internal/DialectFactoryInitiator.java (85%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/dialect/internal/DialectResolverInitiator.java (89%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/dialect/internal/DialectResolverSet.java (96%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/dialect/internal/StandardDialectResolver.java (99%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/dialect/spi/DialectFactory.java (97%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jdbc/dialect/spi/DialectResolver.java (97%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jndi/JndiException.java (97%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jndi/JndiNameException.java (97%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jndi/internal/JndiServiceImpl.java (96%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jndi/internal/JndiServiceInitiator.java (86%) rename hibernate-core/src/main/java/org/hibernate/{service => engine}/jndi/spi/JndiService.java (98%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/AbstractJtaPlatform.java (95%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/BitronixJtaPlatform.java (90%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/BorlandEnterpriseServerJtaPlatform.java (96%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/JBossAppServerJtaPlatform.java (94%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/JBossStandAloneJtaPlatform.java (91%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/JOTMJtaPlatform.java (90%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/JOnASJtaPlatform.java (93%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/JRun4JtaPlatform.java (90%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/JtaPlatformInitiator.java (90%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/JtaSynchronizationStrategy.java (96%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/NoJtaPlatform.java (93%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/OC4JJtaPlatform.java (90%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/OrionJtaPlatform.java (91%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/ResinJtaPlatform.java (91%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/SunOneJtaPlatform.java (89%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/SynchronizationRegistryAccess.java (96%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/SynchronizationRegistryBasedSynchronizationStrategy.java (97%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/TransactionManagerAccess.java (95%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/TransactionManagerBasedSynchronizationStrategy.java (93%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/TransactionManagerLookupBridge.java (94%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/WebSphereExtendedJtaPlatform.java (99%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/WebSphereJtaPlatform.java (95%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/internal/WeblogicJtaPlatform.java (91%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/spi/JtaPlatform.java (98%) rename hibernate-core/src/main/java/org/hibernate/{service => engine/transaction}/jta/platform/spi/JtaPlatformException.java (95%) rename hibernate-core/src/main/java/org/hibernate/{service => }/jmx/internal/DisabledJmxServiceImpl.java (94%) rename hibernate-core/src/main/java/org/hibernate/{service => }/jmx/internal/JmxServiceImpl.java (98%) rename hibernate-core/src/main/java/org/hibernate/{service => }/jmx/internal/JmxServiceInitiator.java (88%) delete mode 100755 hibernate-core/src/main/java/org/hibernate/jmx/package.html rename hibernate-core/src/main/java/org/hibernate/{service => }/jmx/spi/JmxService.java (97%) delete mode 100644 hibernate-core/src/main/java/org/hibernate/service/selector/package-info.java diff --git a/changelog.txt b/changelog.txt index b9ba33f3c0..28b36e1de5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -256,7 +256,7 @@ https://hibernate.onjira.com/browse/HHH/fixforversion/11223 ** Task * [HHH-6082] - Incorporate EntityManager documentation into main dev guide * [HHH-6336] - Add TenantIdentifierResolver - * [HHH-6656] - Document org.hibernate.service.classloading.spi.ClassLoaderService + * [HHH-6656] - Document org.hibernate.boot.registry.classloading.spi.ClassLoaderService * [HHH-6966] - Re apply HHH-6782 * [HHH-6985] - Change up tests for PostgreSQL LockMode issues * [HHH-7011] - Document multi-tenancy diff --git a/documentation/src/main/docbook/devguide/en-US/Database_Access.xml b/documentation/src/main/docbook/devguide/en-US/Database_Access.xml index 5b42be5358..26862e3ddb 100644 --- a/documentation/src/main/docbook/devguide/en-US/Database_Access.xml +++ b/documentation/src/main/docbook/devguide/en-US/Database_Access.xml @@ -32,9 +32,9 @@ Hibernate obtains JDBC connections as needed though the - org.hibernate.service.jdbc.connections.spi.ConnectionProvider interface + ConnectionProvider interface which is a service contract. Applications may also supply their own - org.hibernate.service.jdbc.connections.spi.ConnectionProvider implementation + ConnectionProvider implementation to define a custom approach for supplying connections to Hibernate (from a different connection pool implementation, for example). @@ -232,7 +232,7 @@ You can define your own plugin strategy for obtaining JDBC connections by implementing the interface - org.hibernate.service.jdbc.connections.spi.ConnectionProvider and specifying your custom + ConnectionProvider and specifying your custom implementation with the hibernate.connection.provider_class property. @@ -386,22 +386,22 @@
Dialect resolution - Assuming a org.hibernate.service.jdbc.connections.spi.ConnectionProvider has been + Assuming a ConnectionProvider has been set up, Hibernate will attempt to automatically determine the Dialect to use based on the java.sql.DatabaseMetaData reported by a java.sql.Connection obtained from that - org.hibernate.service.jdbc.connections.spi.ConnectionProvider. + ConnectionProvider. This functionality is provided by a series of - org.hibernate.service.jdbc.dialect.spi.DialectResolver instances registered + org.hibernate.engine.jdbc.dialect.spi.DialectResolver instances registered with Hibernate internally. Hibernate comes with a standard set of recognitions. If your application requires extra Dialect resolution capabilities, it would simply register a custom implementation - of org.hibernate.service.jdbc.dialect.spi.DialectResolver as follows: + of org.hibernate.engine.jdbc.dialect.spi.DialectResolver as follows: - Registered org.hibernate.service.jdbc.dialect.spi.DialectResolver are + Registered org.hibernate.engine.jdbc.dialect.spi.DialectResolver are prepended to an internal list of resolvers, so they take precedence before any already registered resolvers including the standard one. diff --git a/documentation/src/main/docbook/devguide/en-US/chapters/multitenancy/Multi_Tenancy.xml b/documentation/src/main/docbook/devguide/en-US/chapters/multitenancy/Multi_Tenancy.xml index a5a2d0a805..b2432b96f2 100644 --- a/documentation/src/main/docbook/devguide/en-US/chapters/multitenancy/Multi_Tenancy.xml +++ b/documentation/src/main/docbook/devguide/en-US/chapters/multitenancy/Multi_Tenancy.xml @@ -149,7 +149,7 @@ Correlates to the separate schema approach. It is an error to attempt to open a session without a tenant identifier using this strategy. Additionally, a - org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider + MultiTenantConnectionProvider must be specified. @@ -160,7 +160,7 @@ Correlates to the separate database approach. It is an error to attempt to open a session without a tenant identifier using this strategy. Additionally, a - org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider + MultiTenantConnectionProvider must be specified. @@ -182,7 +182,7 @@ When using either the DATABASE or SCHEMA approach, Hibernate needs to be able to obtain Connections in a tenant specific manner. That is the role of the - org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider + MultiTenantConnectionProvider contract. Application developers will need to provide an implementation of this contract. Most of its methods are extremely self-explanatory. The only ones which might not be are getAnyConnection and releaseAnyConnection. It is @@ -205,7 +205,7 @@ - Passed directly to the org.hibernate.service.ServiceRegistryBuilder. + Passed directly to the org.hibernate.boot.registry.StandardServiceRegistryBuilder. @@ -213,7 +213,7 @@ If none of the above options match, but the settings do specify a hibernate.connection.datasource value, Hibernate will assume it should use the specific - org.hibernate.service.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl + DataSourceBasedMultiTenantConnectionProviderImpl implementation which works on a number of pretty reasonable assumptions when running inside of an app server and using one javax.sql.DataSource per tenant. See its javadocs for more details. diff --git a/documentation/src/main/docbook/devguide/en-US/chapters/services/Services.xml b/documentation/src/main/docbook/devguide/en-US/chapters/services/Services.xml index a27e79f6d7..cb40a52da8 100644 --- a/documentation/src/main/docbook/devguide/en-US/chapters/services/Services.xml +++ b/documentation/src/main/docbook/devguide/en-US/chapters/services/Services.xml @@ -81,7 +81,7 @@ same registry as well as any parent registries. - Use org.hibernate.service.ServiceRegistryBuilder to build a + Use org.hibernate.boot.registry.StandardServiceRegistryBuilder to build a org.hibernate.service.ServiceRegistry instance.
@@ -121,7 +121,7 @@
- <interfacename>org.hibernate.service.config.spi.ConfigurationService</interfacename> + <interfacename>org.hibernate.engine.config.spi.ConfigurationService</interfacename> Notes @@ -137,7 +137,7 @@ Initiator - org.hibernate.service.config.internal.ConfigurationServiceInitiator + org.hibernate.engine.config.internal.ConfigurationServiceInitiator @@ -145,7 +145,7 @@ Implementations - org.hibernate.service.config.internal.ConfigurationServiceImpl + org.hibernate.engine.config.internal.ConfigurationServiceImpl @@ -153,7 +153,7 @@
- <interfacename>org.hibernate.service.jdbc.connections.spi.ConnectionProvider</interfacename> + <interfacename>ConnectionProvider</interfacename> Notes @@ -168,7 +168,7 @@ Initiator - org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator + ConnectionProviderInitiator @@ -184,14 +184,14 @@ - org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl - + DatasourceConnectionProviderImpl - provides connection managed delegated to a javax.sql.DataSource - org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl - + DriverManagerConnectionProviderImpl - provides rudimentary connection pooling based on simple custom pool. Note intended production use! @@ -204,7 +204,7 @@ - org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl - + UserSuppliedConnectionProviderImpl - Provides no connection support. Indicates the user will supply connections to Hibernate directly. Not recommended for use. @@ -216,7 +216,7 @@
- <interfacename>org.hibernate.service.jdbc.dialect.spi.DialectFactory</interfacename> + <interfacename>org.hibernate.engine.jdbc.dialect.spi.DialectFactory</interfacename> Notes @@ -233,7 +233,7 @@ Initiator - org.hibernate.service.jdbc.dialect.internal.DialectFactoryInitiator + org.hibernate.engine.jdbc.dialect.internal.DialectFactoryInitiator @@ -241,7 +241,7 @@ Implementations - org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl + org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl @@ -249,7 +249,7 @@
- <interfacename>org.hibernate.service.jdbc.dialect.spi.DialectResolver</interfacename> + <interfacename>org.hibernate.engine.jdbc.dialect.spi.DialectResolver</interfacename> Notes @@ -261,8 +261,8 @@ The standard resolver implementation acts as a chain, delegating to a series of individual resolvers. The standard Hibernate resolution behavior is contained in - org.hibernate.service.jdbc.dialect.internal.StandardDialectResolver. - org.hibernate.service.jdbc.dialect.internal.DialectResolverInitiator + org.hibernate.engine.jdbc.dialect.internal.StandardDialectResolver. + org.hibernate.engine.jdbc.dialect.internal.DialectResolverInitiator also consults with the hibernate.dialect_resolvers setting for any custom resolvers. @@ -272,7 +272,7 @@ Initiator - org.hibernate.service.jdbc.dialect.internal.DialectResolverInitiator + org.hibernate.engine.jdbc.dialect.internal.DialectResolverInitiator @@ -280,7 +280,7 @@ Implementations - org.hibernate.service.jdbc.dialect.internal.DialectResolverSet + org.hibernate.engine.jdbc.dialect.internal.DialectResolverSet @@ -319,7 +319,7 @@
- <interfacename>org.hibernate.service.jmx.spi.JmxService</interfacename> + <interfacename>org.hibernate.jmx.spi.JmxService</interfacename> Notes @@ -333,7 +333,7 @@ Initiator - org.hibernate.service.jmx.internal.JmxServiceInitiator + org.hibernate.jmx.internal.JmxServiceInitiator @@ -343,13 +343,13 @@ - org.hibernate.service.jmx.internal.DisabledJmxServiceImpl - + org.hibernate.jmx.internal.DisabledJmxServiceImpl - A no-op implementation when JMX functionality is disabled. - org.hibernate.service.jmx.internal.JmxServiceImpl - + org.hibernate.jmx.internal.JmxServiceImpl - Standard implementation of JMX handling @@ -360,7 +360,7 @@
- <interfacename>org.hibernate.service.jndi.spi.JndiService</interfacename> + <interfacename>org.hibernate.engine.jndi.spi.JndiService</interfacename> Notes @@ -374,7 +374,7 @@ Initiator - org.hibernate.service.jndi.internal.JndiServiceInitiator + org.hibernate.engine.jndi.internal.JndiServiceInitiator @@ -382,7 +382,7 @@ Implementations - org.hibernate.service.jndi.internal.JndiServiceImpl + org.hibernate.engine.jndi.internal.JndiServiceImpl @@ -390,7 +390,7 @@
- <interfacename>org.hibernate.service.jta.platform.spi.JtaPlatform</interfacename> + <interfacename>org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform</interfacename> Notes @@ -404,7 +404,7 @@ Initiator - org.hibernate.service.jta.platform.internal.JtaPlatformInitiator + org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator @@ -423,81 +423,81 @@ - org.hibernate.service.jta.platform.internal.BitronixJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.BitronixJtaPlatform - Integration with the Bitronix stand-alone transaction manager. - org.hibernate.service.jta.platform.internal.BorlandEnterpriseServerJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.BorlandEnterpriseServerJtaPlatform - Integration with the transaction manager as deployed within a Borland Enterprise Server - org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform - Integration with the transaction manager as deployed within a JBoss Application Server - org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform - Integration with the JBoss Transactions stand-alone transaction manager - org.hibernate.service.jta.platform.internal.JOTMJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.JOTMJtaPlatform - Integration with the JOTM stand-alone transaction manager - org.hibernate.service.jta.platform.internal.JOnASJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.JOnASJtaPlatform - Integration with the JOnAS transaction manager. - org.hibernate.service.jta.platform.internal.JRun4JtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.JRun4JtaPlatform - Integration with the transaction manager as deployed in a JRun 4 application server. - org.hibernate.service.jta.platform.internal.NoJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform - No-op version when no JTA set up is configured - org.hibernate.service.jta.platform.internal.OC4JJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.OC4JJtaPlatform - Integration with transaction manager as deployed in an OC4J (Oracle) application server. - org.hibernate.service.jta.platform.internal.OrionJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.OrionJtaPlatform - Integration with transaction manager as deployed in an Orion application server. - org.hibernate.service.jta.platform.internal.ResinJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.ResinJtaPlatform - Integration with transaction manager as deployed in a Resin application server. - org.hibernate.service.jta.platform.internal.SunOneJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.SunOneJtaPlatform - Integration with transaction manager as deployed in a Sun ONE (7 and above) application server. - org.hibernate.service.jta.platform.internal.TransactionManagerLookupBridge - + org.hibernate.engine.transaction.jta.platform.internal.TransactionManagerLookupBridge - Provides a bridge to legacy (and deprecated) org.hibernate.transaction.TransactionManagerLookup implementations @@ -505,21 +505,21 @@ - org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform - Integration with transaction manager as deployed in a WebSphere Application Server (6 and above). - org.hibernate.service.jta.platform.internal.WebSphereJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform - Integration with transaction manager as deployed in a WebSphere Application Server (4, 5.0 and 5.1). - org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform - + org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform - Integration with transaction manager as deployed in a Weblogic application server. @@ -530,7 +530,7 @@
- <interfacename>org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider</interfacename> + <interfacename>MultiTenantConnectionProvider</interfacename> Notes @@ -875,27 +875,27 @@ Once a org.hibernate.service.ServiceRegistry is built it is considered immutable; the services themselves might accept re-configuration, but immutability here means adding/replacing services. So another role provided by the - org.hibernate.service.ServiceRegistryBuilder is to allow tweaking of the services + org.hibernate.boot.registry.StandardServiceRegistryBuilder is to allow tweaking of the services that will be contained in the org.hibernate.service.ServiceRegistry generated from it. - There are 2 means to tell a org.hibernate.service.ServiceRegistryBuilder about + There are 2 means to tell a org.hibernate.boot.registry.StandardServiceRegistryBuilder about custom services. - Implement a org.hibernate.service.spi.BasicServiceInitiator class + Implement a org.hibernate.boot.registry.StandardServiceInitiator class to control on-demand construction of the service class and add it to the - org.hibernate.service.ServiceRegistryBuilder via its + org.hibernate.boot.registry.StandardServiceRegistryBuilder via its addInitiator method. Just instantiate the service class and add it to the - org.hibernate.service.ServiceRegistryBuilder via its + org.hibernate.boot.registry.StandardServiceRegistryBuilder via its addService method. @@ -921,7 +921,7 @@ Instances of boot-strap registries are built using the - org.hibernate.service.BootstrapServiceRegistryBuilder class. + org.hibernate.boot.registry.BootstrapServiceRegistryBuilder class. @@ -932,7 +932,7 @@
Bootstrap registry services
- <interfacename>org.hibernate.service.classloading.spi.ClassLoaderService</interfacename> + <interfacename>org.hibernate.boot.registry.classloading.spi.ClassLoaderService</interfacename> Hibernate needs to interact with ClassLoaders. However, the manner in which Hibernate (or any library) should interact with ClassLoaders varies based on the runtime environment @@ -986,7 +986,7 @@ This service focuses on the discovery aspect. It leverages the standard Java java.util.ServiceLoader capability provided by the - org.hibernate.service.classloading.spi.ClassLoaderService + org.hibernate.boot.registry.classloading.spi.ClassLoaderService in order to discover implementations of the org.hibernate.integrator.spi.Integrator contract. Integrators would simply define a file named diff --git a/documentation/src/main/docbook/devguide/en-US/chapters/transactions/Transactions.xml b/documentation/src/main/docbook/devguide/en-US/chapters/transactions/Transactions.xml index 2aa3e844d1..9b282aa80b 100644 --- a/documentation/src/main/docbook/devguide/en-US/chapters/transactions/Transactions.xml +++ b/documentation/src/main/docbook/devguide/en-US/chapters/transactions/Transactions.xml @@ -95,7 +95,7 @@ JTA-based transaction approach which leverages the javax.transaction.UserTransaction interface as obtained from - org.hibernate.service.jta.platform.spi.JtaPlatform API. This approach + org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform API. This approach is represented by the org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory class. @@ -111,7 +111,7 @@ Another JTA-based transaction approach which leverages the JTA javax.transaction.TransactionManager interface as obtained from - org.hibernate.service.jta.platform.spi.JtaPlatform API. This approach + org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform API. This approach is represented by the org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory class. In an actual JEE CMT environment, access to the diff --git a/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java b/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java index e9feac5f44..61238d83f5 100644 --- a/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java +++ b/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java @@ -35,11 +35,12 @@ import org.jboss.logging.Logger; import org.hibernate.HibernateException; import org.hibernate.cfg.Environment; +import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.UnknownUnwrapTypeException; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.classloading.spi.ClassLoadingException; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.spi.Configurable; import org.hibernate.service.spi.ServiceRegistryAwareService; import org.hibernate.service.spi.ServiceRegistryImplementor; diff --git a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java index af61d3b84d..2175f15193 100644 --- a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java +++ b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java @@ -32,7 +32,7 @@ import org.junit.Test; import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; diff --git a/hibernate-core/src/main/java/org/hibernate/SessionFactory.java b/hibernate-core/src/main/java/org/hibernate/SessionFactory.java index 827b5a77ee..a4020d905f 100644 --- a/hibernate-core/src/main/java/org/hibernate/SessionFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/SessionFactory.java @@ -71,7 +71,7 @@ public interface SessionFactory extends Referenceable, Serializable { * Open a {@link Session}. *

* JDBC {@link Connection connection(s} will be obtained from the - * configured {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} as needed + * configured {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} as needed * to perform requested work. * * @return The created session. diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistry.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistry.java new file mode 100644 index 0000000000..d7d9387225 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistry.java @@ -0,0 +1,35 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.boot.registry; + +import org.hibernate.service.ServiceRegistry; + +/** + * Specialization of the {@link org.hibernate.service.ServiceRegistry} contract mainly to make the + * {@link StandardServiceRegistryBuilder#StandardServiceRegistryBuilder(BootstrapServiceRegistry)} signature type-safe + * + * @author Steve Ebersole + */ +public interface BootstrapServiceRegistry extends ServiceRegistry { +} diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java new file mode 100644 index 0000000000..db33fef5eb --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java @@ -0,0 +1,152 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.boot.registry; + +import java.util.LinkedHashSet; + +import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl; +import org.hibernate.integrator.internal.IntegratorServiceImpl; +import org.hibernate.integrator.spi.Integrator; +import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl; +import org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder; + +/** + * Builder for bootstrap {@link org.hibernate.service.ServiceRegistry} instances. + * + * @author Steve Ebersole + * + * @see BootstrapServiceRegistryImpl + * @see StandardServiceRegistryBuilder#StandardServiceRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistry) + */ +public class BootstrapServiceRegistryBuilder { + private final LinkedHashSet providedIntegrators = new LinkedHashSet(); + private ClassLoader applicationClassLoader; + private ClassLoader resourcesClassLoader; + private ClassLoader hibernateClassLoader; + private ClassLoader environmentClassLoader; + + private StrategySelectorBuilder strategySelectorBuilder = new StrategySelectorBuilder(); + + /** + * Add an {@link Integrator} to be applied to the bootstrap registry. + * + * @param integrator The integrator to add. + * @return {@code this}, for method chaining + */ + public BootstrapServiceRegistryBuilder with(Integrator integrator) { + providedIntegrators.add( integrator ); + return this; + } + + /** + * Applies the specified {@link ClassLoader} as the application class loader for the bootstrap registry + * + * @param classLoader The class loader to use + * @return {@code this}, for method chaining + */ + @SuppressWarnings( {"UnusedDeclaration"}) + public BootstrapServiceRegistryBuilder withApplicationClassLoader(ClassLoader classLoader) { + this.applicationClassLoader = classLoader; + return this; + } + + /** + * Applies the specified {@link ClassLoader} as the resource class loader for the bootstrap registry + * + * @param classLoader The class loader to use + * @return {@code this}, for method chaining + */ + @SuppressWarnings( {"UnusedDeclaration"}) + public BootstrapServiceRegistryBuilder withResourceClassLoader(ClassLoader classLoader) { + this.resourcesClassLoader = classLoader; + return this; + } + + /** + * Applies the specified {@link ClassLoader} as the Hibernate class loader for the bootstrap registry + * + * @param classLoader The class loader to use + * @return {@code this}, for method chaining + */ + @SuppressWarnings( {"UnusedDeclaration"}) + public BootstrapServiceRegistryBuilder withHibernateClassLoader(ClassLoader classLoader) { + this.hibernateClassLoader = classLoader; + return this; + } + + /** + * Applies the specified {@link ClassLoader} as the environment (or system) class loader for the bootstrap registry + * + * @param classLoader The class loader to use + * @return {@code this}, for method chaining + */ + @SuppressWarnings( {"UnusedDeclaration"}) + public BootstrapServiceRegistryBuilder withEnvironmentClassLoader(ClassLoader classLoader) { + this.environmentClassLoader = classLoader; + return this; + } + + /** + * Applies a named strategy implementation to the bootstrap registry + * + * @param strategy The strategy + * @param name The registered name + * @param implementation The strategy implementation Class + * + * @return {@code this}, for method chaining + * + * @see org.hibernate.boot.registry.selector.spi.StrategySelector#registerStrategyImplementor(Class, String, Class) + */ + @SuppressWarnings( {"UnusedDeclaration"}) + public BootstrapServiceRegistryBuilder withStrategySelector(Class strategy, String name, Class implementation) { + this.strategySelectorBuilder.addCustomRegistration( strategy, name, implementation ); + return this; + } + + /** + * Build the bootstrap registry. + * + * @return The built bootstrap registry + */ + public BootstrapServiceRegistry build() { + final ClassLoaderServiceImpl classLoaderService = new ClassLoaderServiceImpl( + applicationClassLoader, + resourcesClassLoader, + hibernateClassLoader, + environmentClassLoader + ); + + final IntegratorServiceImpl integratorService = new IntegratorServiceImpl( + providedIntegrators, + classLoaderService + ); + + + return new BootstrapServiceRegistryImpl( + classLoaderService, + strategySelectorBuilder.buildSelector( classLoaderService ), + integratorService + ); + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/service/spi/BasicServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/service/spi/BasicServiceInitiator.java rename to hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java index 1235549ff6..ceeb6cb1e6 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/spi/BasicServiceInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java @@ -21,18 +21,20 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.spi; +package org.hibernate.boot.registry; import java.util.Map; import org.hibernate.service.Service; +import org.hibernate.service.spi.ServiceInitiator; +import org.hibernate.service.spi.ServiceRegistryImplementor; /** * Contract for an initiator of services that target the standard {@link org.hibernate.service.ServiceRegistry} * * @author Steve Ebersole */ -public interface BasicServiceInitiator extends ServiceInitiator { +public interface StandardServiceInitiator extends ServiceInitiator { /** * Initiates the managed service. * diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java new file mode 100644 index 0000000000..0e2d7e3877 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java @@ -0,0 +1,224 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.boot.registry; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.hibernate.cfg.Environment; +import org.hibernate.integrator.spi.Integrator; +import org.hibernate.integrator.spi.IntegratorService; +import org.hibernate.integrator.spi.ServiceContributingIntegrator; +import org.hibernate.internal.jaxb.cfg.JaxbHibernateConfiguration; +import org.hibernate.internal.util.config.ConfigurationHelper; +import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl; +import org.hibernate.service.ConfigLoader; +import org.hibernate.service.Service; +import org.hibernate.service.ServiceRegistry; +import org.hibernate.service.StandardServiceInitiators; +import org.hibernate.service.internal.ProvidedService; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; + +/** + * Builder for standard {@link org.hibernate.service.ServiceRegistry} instances. + * + * @author Steve Ebersole + * + * @see StandardServiceRegistryImpl + * @see org.hibernate.boot.registry.BootstrapServiceRegistryBuilder + */ +public class StandardServiceRegistryBuilder { + public static final String DEFAULT_CFG_RESOURCE_NAME = "hibernate.cfg.xml"; + + private final Map settings; + private final List initiators = standardInitiatorList(); + private final List providedServices = new ArrayList(); + + private final BootstrapServiceRegistry bootstrapServiceRegistry; + private final ConfigLoader configLoader; + + /** + * Create a default builder + */ + public StandardServiceRegistryBuilder() { + this( new BootstrapServiceRegistryImpl() ); + } + + /** + * Create a builder with the specified bootstrap services. + * + * @param bootstrapServiceRegistry Provided bootstrap registry to use. + */ + public StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry) { + this.settings = Environment.getProperties(); + this.bootstrapServiceRegistry = bootstrapServiceRegistry; + this.configLoader = new ConfigLoader( bootstrapServiceRegistry ); + } + + /** + * Used from the {@link #initiators} variable initializer + * + * @return List of standard initiators + */ + private static List standardInitiatorList() { + final List initiators = new ArrayList(); + initiators.addAll( StandardServiceInitiators.LIST ); + return initiators; + } + + /** + * Read settings from a {@link Properties} file. Differs from {@link #configure()} and {@link #configure(String)} + * in that here we read a {@link Properties} file while for {@link #configure} we read the XML variant. + * + * @param resourceName The name by which to perform a resource look up for the properties file. + * + * @return this, for method chaining + * + * @see #configure() + * @see #configure(String) + */ + @SuppressWarnings( {"unchecked"}) + public StandardServiceRegistryBuilder loadProperties(String resourceName) { + settings.putAll( configLoader.loadProperties( resourceName ) ); + return this; + } + + /** + * Read setting information from an XML file using the standard resource location + * + * @return this, for method chaining + * + * @see #DEFAULT_CFG_RESOURCE_NAME + * @see #configure(String) + * @see #loadProperties(String) + */ + public StandardServiceRegistryBuilder configure() { + return configure( DEFAULT_CFG_RESOURCE_NAME ); + } + + /** + * Read setting information from an XML file using the named resource location + * + * @param resourceName The named resource + * + * @return this, for method chaining + * + * @see #loadProperties(String) + */ + @SuppressWarnings( {"unchecked"}) + public StandardServiceRegistryBuilder configure(String resourceName) { + JaxbHibernateConfiguration configurationElement = configLoader.loadConfigXmlResource( resourceName ); + for ( JaxbHibernateConfiguration.JaxbSessionFactory.JaxbProperty xmlProperty : configurationElement.getSessionFactory().getProperty() ) { + settings.put( xmlProperty.getName(), xmlProperty.getValue() ); + } + + return this; + } + + /** + * Apply a setting value + * + * @param settingName The name of the setting + * @param value The value to use. + * + * @return this, for method chaining + */ + @SuppressWarnings( {"unchecked", "UnusedDeclaration"}) + public StandardServiceRegistryBuilder applySetting(String settingName, Object value) { + settings.put( settingName, value ); + return this; + } + + /** + * Apply a groups of setting values + * + * @param settings The incoming settings to apply + * + * @return this, for method chaining + */ + @SuppressWarnings( {"unchecked", "UnusedDeclaration"}) + public StandardServiceRegistryBuilder applySettings(Map settings) { + this.settings.putAll( settings ); + return this; + } + + /** + * Adds a service initiator. + * + * @param initiator The initiator to be added + * + * @return this, for method chaining + */ + @SuppressWarnings( {"UnusedDeclaration"}) + public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) { + initiators.add( initiator ); + return this; + } + + /** + * Adds a user-provided service + * + * @param serviceRole The role of the service being added + * @param service The service implementation + * + * @return this, for method chaining + */ + @SuppressWarnings( {"unchecked"}) + public StandardServiceRegistryBuilder addService(final Class serviceRole, final Service service) { + providedServices.add( new ProvidedService( serviceRole, service ) ); + return this; + } + + /** + * Build the service registry accounting for all settings and service initiators and services. + * + * @return The built service registry + */ + public ServiceRegistry buildServiceRegistry() { + Map settingsCopy = new HashMap(); + settingsCopy.putAll( settings ); + Environment.verifyProperties( settingsCopy ); + ConfigurationHelper.resolvePlaceHolders( settingsCopy ); + + for ( Integrator integrator : bootstrapServiceRegistry.getService( IntegratorService.class ).getIntegrators() ) { + if ( ServiceContributingIntegrator.class.isInstance( integrator ) ) { + ServiceContributingIntegrator.class.cast( integrator ).prepareServices( this ); + } + } + + return new StandardServiceRegistryImpl( bootstrapServiceRegistry, initiators, providedServices, settingsCopy ); + } + + /** + * Destroy a service registry. Applications should only destroy registries they have explicitly created. + * + * @param serviceRegistry The registry to be closed. + */ + public static void destroy(ServiceRegistry serviceRegistry) { + ( (StandardServiceRegistryImpl) serviceRegistry ).destroy(); + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/service/classloading/internal/ClassLoaderServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/service/classloading/internal/ClassLoaderServiceImpl.java rename to hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java index f069ddfc86..bf2b37a391 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/classloading/internal/ClassLoaderServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.classloading.internal; +package org.hibernate.boot.registry.classloading.internal; import java.io.IOException; import java.io.InputStream; @@ -38,8 +38,8 @@ import java.util.ServiceLoader; import org.jboss.logging.Logger; import org.hibernate.cfg.AvailableSettings; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.classloading.spi.ClassLoadingException; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; /** * Standard implementation of the service for interacting with class loaders diff --git a/hibernate-core/src/main/java/org/hibernate/service/classloading/spi/ClassLoaderService.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoaderService.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/classloading/spi/ClassLoaderService.java rename to hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoaderService.java index 5bbd2a0555..cc4cbe4d02 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/classloading/spi/ClassLoaderService.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoaderService.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.classloading.spi; +package org.hibernate.boot.registry.classloading.spi; import java.io.InputStream; import java.net.URL; diff --git a/hibernate-core/src/main/java/org/hibernate/service/classloading/spi/ClassLoadingException.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoadingException.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/service/classloading/spi/ClassLoadingException.java rename to hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoadingException.java index b7219ae444..ce02f02f99 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/classloading/spi/ClassLoadingException.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoadingException.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.classloading.spi; +package org.hibernate.boot.registry.classloading.spi; import org.hibernate.HibernateException; /** diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/BootstrapServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/BootstrapServiceRegistryImpl.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/service/internal/BootstrapServiceRegistryImpl.java rename to hibernate-core/src/main/java/org/hibernate/boot/registry/internal/BootstrapServiceRegistryImpl.java index 3659ce8b71..2780846ea3 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/BootstrapServiceRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/BootstrapServiceRegistryImpl.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 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 Inc. @@ -21,20 +21,20 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.internal; +package org.hibernate.boot.registry.internal; import java.util.LinkedHashSet; import org.hibernate.integrator.internal.IntegratorServiceImpl; import org.hibernate.integrator.spi.Integrator; import org.hibernate.integrator.spi.IntegratorService; -import org.hibernate.service.BootstrapServiceRegistry; +import org.hibernate.boot.registry.BootstrapServiceRegistry; import org.hibernate.service.Service; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.selector.internal.StrategySelectorImpl; -import org.hibernate.service.selector.spi.StrategySelector; +import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.selector.internal.StrategySelectorImpl; +import org.hibernate.boot.registry.selector.spi.StrategySelector; import org.hibernate.service.spi.ServiceBinding; import org.hibernate.service.spi.ServiceException; import org.hibernate.service.spi.ServiceInitiator; @@ -46,6 +46,11 @@ import org.hibernate.service.spi.ServiceRegistryImplementor; *

  • {@link IntegratorService}
  • * * + * IMPL NOTE : Currently implements the deprecated {@link org.hibernate.service.BootstrapServiceRegistry} contract + * so that the registry returned from the builder works on the deprecated sense. Once + * {@link org.hibernate.service.BootstrapServiceRegistry} goes away, this should be updated to instead implement + * {@link org.hibernate.boot.registry.BootstrapServiceRegistry}. + * * @author Steve Ebersole */ public class BootstrapServiceRegistryImpl diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/StandardServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/StandardServiceRegistryImpl.java similarity index 85% rename from hibernate-core/src/main/java/org/hibernate/service/internal/StandardServiceRegistryImpl.java rename to hibernate-core/src/main/java/org/hibernate/boot/registry/internal/StandardServiceRegistryImpl.java index f55423e977..23717955bc 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/StandardServiceRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/StandardServiceRegistryImpl.java @@ -21,15 +21,17 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.internal; +package org.hibernate.boot.registry.internal; import java.util.List; import java.util.Map; -import org.hibernate.service.BootstrapServiceRegistry; +import org.hibernate.boot.registry.StandardServiceInitiator; +import org.hibernate.boot.registry.BootstrapServiceRegistry; import org.hibernate.service.Service; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.service.internal.AbstractServiceRegistryImpl; +import org.hibernate.service.internal.ProvidedService; import org.hibernate.service.spi.Configurable; import org.hibernate.service.spi.ServiceBinding; import org.hibernate.service.spi.ServiceInitiator; @@ -45,7 +47,7 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp @SuppressWarnings( {"unchecked"}) public StandardServiceRegistryImpl( BootstrapServiceRegistry bootstrapServiceRegistry, - List serviceInitiators, + List serviceInitiators, List providedServices, Map configurationValues) { super( bootstrapServiceRegistry ); @@ -66,7 +68,7 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp @Override public R initiateService(ServiceInitiator serviceInitiator) { // todo : add check/error for unexpected initiator types? - return ( (BasicServiceInitiator) serviceInitiator ).initiateService( configurationValues, this ); + return ( (StandardServiceInitiator) serviceInitiator ).initiateService( configurationValues, this ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorBuilder.java rename to hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java index 54002abb84..1cce52e67b 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.selector.internal; +package org.hibernate.boot.registry.selector.internal; import java.util.ArrayList; import java.util.List; @@ -32,9 +32,9 @@ import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory; import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory; import org.hibernate.engine.transaction.spi.TransactionFactory; -import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl; -import org.hibernate.service.selector.spi.StrategySelectionException; -import org.hibernate.service.selector.spi.StrategySelector; +import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl; +import org.hibernate.boot.registry.selector.spi.StrategySelectionException; +import org.hibernate.boot.registry.selector.spi.StrategySelector; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorImpl.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorImpl.java rename to hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorImpl.java index 42e2d45e01..9d7c6b98e4 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/selector/internal/StrategySelectorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorImpl.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.selector.internal; +package org.hibernate.boot.registry.selector.internal; import java.util.Iterator; import java.util.Map; @@ -29,10 +29,10 @@ import java.util.concurrent.ConcurrentHashMap; import org.jboss.logging.Logger; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.classloading.spi.ClassLoadingException; -import org.hibernate.service.selector.spi.StrategySelectionException; -import org.hibernate.service.selector.spi.StrategySelector; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; +import org.hibernate.boot.registry.selector.spi.StrategySelectionException; +import org.hibernate.boot.registry.selector.spi.StrategySelector; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/package-info.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/package-info.java new file mode 100644 index 0000000000..095e5ca34b --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/package-info.java @@ -0,0 +1 @@ +package org.hibernate.boot.registry.selector; \ No newline at end of file diff --git a/hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelectionException.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelectionException.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelectionException.java rename to hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelectionException.java index 5caf1e2804..01b63580be 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelectionException.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelectionException.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.selector.spi; +package org.hibernate.boot.registry.selector.spi; import org.hibernate.HibernateException; diff --git a/hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelector.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelector.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelector.java rename to hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelector.java index 222c4dc047..21012a25fb 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/selector/spi/StrategySelector.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelector.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.selector.spi; +package org.hibernate.boot.registry.selector.spi; import org.hibernate.service.Service; diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java index 4089bd846f..6a2002f591 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java @@ -25,9 +25,9 @@ package org.hibernate.cache.internal; import java.util.Map; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.cache.spi.RegionFactory; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.service.spi.ServiceException; import org.hibernate.service.spi.ServiceRegistryImplementor; @@ -36,7 +36,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor; * * @author Hardy Ferentschik */ -public class RegionFactoryInitiator implements BasicServiceInitiator { +public class RegionFactoryInitiator implements StandardServiceInitiator { public static final RegionFactoryInitiator INSTANCE = new RegionFactoryInitiator(); /** diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java index 4a55bb0c36..351d2600e3 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java @@ -44,10 +44,10 @@ public interface AvailableSettings { public static final String SESSION_FACTORY_NAME_IS_JNDI = "hibernate.session_factory_name_is_jndi"; /** - * Names the {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} to use for obtaining + * Names the {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} to use for obtaining * JDBC connections. Can either reference an instance of - * {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} or a {@link Class} or {@link String} - * reference to the {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} implementation + * {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} or a {@link Class} or {@link String} + * reference to the {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} implementation * class. */ public static final String CONNECTION_PROVIDER ="hibernate.connection.provider_class"; @@ -64,7 +64,7 @@ public interface AvailableSettings { /** * Names the connection user. This might mean one of 2 things in out-of-the-box Hibernate - * {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider}:
      + * {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider}:
        *
      • The username used to pass along to creating the JDBC connection
      • *
      • The username used to obtain a JDBC connection from a data source
      • *
      @@ -129,8 +129,8 @@ public interface AvailableSettings { public static final String DIALECT ="hibernate.dialect"; /** - * Names any additional {@link org.hibernate.service.jdbc.dialect.spi.DialectResolver} implementations to - * register with the standard {@link org.hibernate.service.jdbc.dialect.spi.DialectFactory}. + * Names any additional {@link org.hibernate.engine.jdbc.dialect.spi.DialectResolver} implementations to + * register with the standard {@link org.hibernate.engine.jdbc.dialect.spi.DialectFactory}. */ public static final String DIALECT_RESOLVERS = "hibernate.dialect_resolvers"; @@ -275,9 +275,9 @@ public interface AvailableSettings { public static final String TRANSACTION_STRATEGY = "hibernate.transaction.factory_class"; /** - * Names the {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation to use for integrating - * with {@literal JTA} systems. Can reference either a {@link org.hibernate.service.jta.platform.spi.JtaPlatform} - * instance or the name of the {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation class + * Names the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation to use for integrating + * with {@literal JTA} systems. Can reference either a {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} + * instance or the name of the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation class * @since 4.0 */ public static final String JTA_PLATFORM = "hibernate.transaction.jta.platform"; @@ -570,9 +570,9 @@ public interface AvailableSettings { public static final String MULTI_TENANT = "hibernate.multiTenancy"; /** - * Names a {@link org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider} implementation to + * Names a {@link org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider} implementation to * use. As MultiTenantConnectionProvider is also a service, can be configured directly through the - * {@link org.hibernate.service.ServiceRegistryBuilder} + * {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder} * * @since 4.1 */ diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java index 53d7415a51..306b9917b3 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java @@ -81,6 +81,7 @@ import org.hibernate.annotations.common.reflection.MetadataProviderInjector; import org.hibernate.annotations.common.reflection.ReflectionManager; import org.hibernate.annotations.common.reflection.XClass; import org.hibernate.annotations.common.reflection.java.JavaReflectionManager; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.annotations.reflection.JPAMetadataProvider; import org.hibernate.context.spi.CurrentTenantIdentifierResolver; import org.hibernate.dialect.Dialect; @@ -136,8 +137,7 @@ import org.hibernate.mapping.UniqueKey; import org.hibernate.proxy.EntityNotFoundDelegate; import org.hibernate.secure.internal.JACCConfiguration; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.tool.hbm2ddl.DatabaseMetadata; import org.hibernate.tool.hbm2ddl.IndexMetadata; import org.hibernate.tool.hbm2ddl.TableMetadata; @@ -163,7 +163,7 @@ import org.hibernate.usertype.UserType; * A new Configuration will use the properties specified in * hibernate.properties by default. *

      - * NOTE : This will be replaced by use of {@link ServiceRegistryBuilder} and + * NOTE : This will be replaced by use of {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder} and * {@link org.hibernate.metamodel.MetadataSources} instead after the 4.0 release at which point this class will become * deprecated and scheduled for removal in 5.0. See * HHH-6183, @@ -1770,7 +1770,7 @@ public class Configuration implements Serializable { public SessionFactory buildSessionFactory() throws HibernateException { Environment.verifyProperties( properties ); ConfigurationHelper.resolvePlaceHolders( properties ); - final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder() + final ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder() .applySettings( properties ) .buildServiceRegistry(); setSessionFactoryObserver( diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java b/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java index 825d156386..8cc6667472 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java @@ -76,7 +76,7 @@ import org.hibernate.internal.util.config.ConfigurationHelper; * * * hibernate.connection.provider_class - * classname of org.hibernate.service.jdbc.connections.spi.ConnectionProvider + * classname of ConnectionProvider * subclass (if not specified hueristics are used) * * hibernate.connection.usernamedatabase username diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Settings.java b/hibernate-core/src/main/java/org/hibernate/cfg/Settings.java index 0a155ae00a..2529b656c1 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Settings.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Settings.java @@ -31,7 +31,7 @@ import org.hibernate.MultiTenancyStrategy; import org.hibernate.cache.spi.QueryCacheFactory; import org.hibernate.cache.spi.RegionFactory; import org.hibernate.hql.spi.QueryTranslatorFactory; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.tuple.entity.EntityTuplizerFactory; /** diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java b/hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java index d157ca406f..0eedef4f7e 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java @@ -46,10 +46,10 @@ import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.tuple.entity.EntityTuplizerFactory; /** diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java index 927e4d6f8f..8b55cda316 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java @@ -43,7 +43,7 @@ import org.hibernate.integrator.spi.Integrator; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.metamodel.source.MetadataImplementor; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.service.spi.SessionFactoryServiceRegistry; /** diff --git a/hibernate-core/src/main/java/org/hibernate/context/internal/JTASessionContext.java b/hibernate-core/src/main/java/org/hibernate/context/internal/JTASessionContext.java index 5c4397bb34..f33a7e2502 100644 --- a/hibernate-core/src/main/java/org/hibernate/context/internal/JTASessionContext.java +++ b/hibernate-core/src/main/java/org/hibernate/context/internal/JTASessionContext.java @@ -39,7 +39,7 @@ import org.hibernate.context.spi.CurrentSessionContext; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper; import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; /** * An implementation of {@link CurrentSessionContext} which scopes the notion diff --git a/hibernate-core/src/main/java/org/hibernate/service/config/internal/ConfigurationServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceImpl.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/service/config/internal/ConfigurationServiceImpl.java rename to hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceImpl.java index 4c03d5f844..5118c5e782 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/config/internal/ConfigurationServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceImpl.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.config.internal; +package org.hibernate.engine.config.internal; import java.util.Collections; import java.util.Map; @@ -29,9 +29,9 @@ import java.util.Map; import org.jboss.logging.Logger; import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.classloading.spi.ClassLoadingException; -import org.hibernate.service.config.spi.ConfigurationService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; +import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.service.spi.ServiceRegistryAwareService; import org.hibernate.service.spi.ServiceRegistryImplementor; diff --git a/hibernate-core/src/main/java/org/hibernate/service/config/internal/ConfigurationServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceInitiator.java similarity index 85% rename from hibernate-core/src/main/java/org/hibernate/service/config/internal/ConfigurationServiceInitiator.java rename to hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceInitiator.java index 610734ca8f..ff382aeb87 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/config/internal/ConfigurationServiceInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceInitiator.java @@ -21,18 +21,18 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.config.internal; +package org.hibernate.engine.config.internal; import java.util.Map; -import org.hibernate.service.config.spi.ConfigurationService; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.StandardServiceInitiator; +import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.service.spi.ServiceRegistryImplementor; /** * @author Steve Ebersole */ -public class ConfigurationServiceInitiator implements BasicServiceInitiator { +public class ConfigurationServiceInitiator implements StandardServiceInitiator { public static final ConfigurationServiceInitiator INSTANCE = new ConfigurationServiceInitiator(); public ConfigurationService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { diff --git a/hibernate-core/src/main/java/org/hibernate/service/config/spi/ConfigurationService.java b/hibernate-core/src/main/java/org/hibernate/engine/config/spi/ConfigurationService.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/service/config/spi/ConfigurationService.java rename to hibernate-core/src/main/java/org/hibernate/engine/config/spi/ConfigurationService.java index 6f8381f604..de5a4fb955 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/config/spi/ConfigurationService.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/config/spi/ConfigurationService.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.config.spi; +package org.hibernate.engine.config.spi; import java.util.Map; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilderInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilderInitiator.java index fda0204233..374a51edd3 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilderInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilderInitiator.java @@ -25,11 +25,11 @@ package org.hibernate.engine.jdbc.batch.internal; import java.util.Map; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.cfg.Environment; import org.hibernate.engine.jdbc.batch.spi.BatchBuilder; import org.hibernate.internal.util.config.ConfigurationHelper; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.service.spi.ServiceException; import org.hibernate.service.spi.ServiceRegistryImplementor; @@ -38,7 +38,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor; * * @author Steve Ebersole */ -public class BatchBuilderInitiator implements BasicServiceInitiator { +public class BatchBuilderInitiator implements StandardServiceInitiator { public static final BatchBuilderInitiator INSTANCE = new BatchBuilderInitiator(); public static final String BUILDER = "hibernate.jdbc.batch.builder"; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/ConnectionProviderInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionProviderInitiator.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/ConnectionProviderInitiator.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionProviderInitiator.java index fc0fc667d5..cde05919ce 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/ConnectionProviderInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionProviderInitiator.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.connections.internal; +package org.hibernate.engine.jdbc.connections.internal; import java.beans.BeanInfo; import java.beans.PropertyDescriptor; @@ -36,13 +36,13 @@ import org.jboss.logging.Logger; import org.hibernate.HibernateException; import org.hibernate.MultiTenancyStrategy; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Environment; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.beans.BeanInfoHelper; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.spi.ServiceRegistryImplementor; /** @@ -51,7 +51,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor; * @author Gavin King * @author Steve Ebersole */ -public class ConnectionProviderInitiator implements BasicServiceInitiator { +public class ConnectionProviderInitiator implements StandardServiceInitiator { public static final ConnectionProviderInitiator INSTANCE = new ConnectionProviderInitiator(); private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/DatasourceConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DatasourceConnectionProviderImpl.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/DatasourceConnectionProviderImpl.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DatasourceConnectionProviderImpl.java index 98ba729b6a..71b6e7f10c 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/DatasourceConnectionProviderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DatasourceConnectionProviderImpl.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.connections.internal; +package org.hibernate.engine.jdbc.connections.internal; import java.sql.Connection; import java.sql.SQLException; import java.util.Map; @@ -29,15 +29,15 @@ import javax.sql.DataSource; import org.hibernate.HibernateException; import org.hibernate.cfg.Environment; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.UnknownUnwrapTypeException; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.service.jndi.spi.JndiService; +import org.hibernate.engine.jndi.spi.JndiService; import org.hibernate.service.spi.Configurable; import org.hibernate.service.spi.InjectService; import org.hibernate.service.spi.Stoppable; /** - * A {@link ConnectionProvider} that manages connections from an underlying {@link DataSource}. + * A {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} that manages connections from an underlying {@link DataSource}. *

      * The {@link DataSource} to use may be specified by either:

        *
      • injection via {@link #setDataSource}
      • diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java index 85f8874005..3b9d67da7b 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.connections.internal; +package org.hibernate.engine.jdbc.connections.internal; import java.sql.Connection; import java.sql.DriverManager; @@ -35,13 +35,13 @@ import org.jboss.logging.Logger; import org.hibernate.HibernateException; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Environment; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.UnknownUnwrapTypeException; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.classloading.spi.ClassLoadingException; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.service.spi.Configurable; import org.hibernate.service.spi.ServiceRegistryAwareService; import org.hibernate.service.spi.ServiceRegistryImplementor; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java similarity index 85% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java index 3605291df4..deedad18f7 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java @@ -21,26 +21,26 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.connections.internal; +package org.hibernate.engine.jdbc.connections.internal; import java.util.Map; import org.jboss.logging.Logger; import org.hibernate.MultiTenancyStrategy; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.cfg.AvailableSettings; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.classloading.spi.ClassLoadingException; -import org.hibernate.service.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl; -import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; +import org.hibernate.engine.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl; +import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider; import org.hibernate.service.spi.ServiceException; import org.hibernate.service.spi.ServiceRegistryImplementor; /** * @author Steve Ebersole */ -public class MultiTenantConnectionProviderInitiator implements BasicServiceInitiator { +public class MultiTenantConnectionProviderInitiator implements StandardServiceInitiator { public static final MultiTenantConnectionProviderInitiator INSTANCE = new MultiTenantConnectionProviderInitiator(); private static final Logger log = Logger.getLogger( MultiTenantConnectionProviderInitiator.class ); @@ -60,7 +60,7 @@ public class MultiTenantConnectionProviderInitiator implements BasicServiceIniti final Object configValue = configurationValues.get( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER ); if ( configValue == null ) { // if they also specified the data source *name*, then lets assume they want - // org.hibernate.service.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl + // DataSourceBasedMultiTenantConnectionProviderImpl final Object dataSourceConfigValue = configurationValues.get( AvailableSettings.DATASOURCE ); if ( dataSourceConfigValue != null && String.class.isInstance( dataSourceConfigValue ) ) { return new DataSourceBasedMultiTenantConnectionProviderImpl(); diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java index f17e319694..b7c966ea4b 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java @@ -21,12 +21,12 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.connections.internal; +package org.hibernate.engine.jdbc.connections.internal; import java.sql.Connection; import java.sql.SQLException; import org.hibernate.service.UnknownUnwrapTypeException; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; /** * An implementation of the {@link ConnectionProvider} interface that simply throws an exception when a connection diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java index 9c2bc3e2e5..b60d3433d0 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.connections.spi; +package org.hibernate.engine.jdbc.connections.spi; import java.sql.Connection; import java.sql.SQLException; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java index 8460a96acf..cd543ec6be 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.connections.spi; +package org.hibernate.engine.jdbc.connections.spi; import java.sql.Connection; import java.sql.SQLException; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/ConnectionProvider.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/ConnectionProvider.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/ConnectionProvider.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/ConnectionProvider.java index dd41e81a88..762d5b4613 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/ConnectionProvider.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/ConnectionProvider.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.connections.spi; +package org.hibernate.engine.jdbc.connections.spi; import java.sql.Connection; import java.sql.SQLException; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java index cbc119b054..cb387f1421 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.connections.spi; +package org.hibernate.engine.jdbc.connections.spi; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -30,8 +30,8 @@ import javax.sql.DataSource; import org.hibernate.HibernateException; import org.hibernate.cfg.AvailableSettings; -import org.hibernate.service.config.spi.ConfigurationService; -import org.hibernate.service.jndi.spi.JndiService; +import org.hibernate.engine.config.spi.ConfigurationService; +import org.hibernate.engine.jndi.spi.JndiService; import org.hibernate.service.spi.ServiceRegistryAwareService; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.Stoppable; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/MultiTenantConnectionProvider.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/MultiTenantConnectionProvider.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/MultiTenantConnectionProvider.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/MultiTenantConnectionProvider.java index 29ce194997..860d926c0b 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/MultiTenantConnectionProvider.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/MultiTenantConnectionProvider.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.connections.spi; +package org.hibernate.engine.jdbc.connections.spi; import java.sql.Connection; import java.sql.SQLException; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/internal/RefCursorSupportInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/RefCursorSupportInitiator.java similarity index 84% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/internal/RefCursorSupportInitiator.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/RefCursorSupportInitiator.java index 7c7cc4fe11..2a74fe146e 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/internal/RefCursorSupportInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/RefCursorSupportInitiator.java @@ -21,18 +21,18 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.cursor.internal; +package org.hibernate.engine.jdbc.cursor.internal; import java.util.Map; -import org.hibernate.service.jdbc.cursor.spi.RefCursorSupport; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.StandardServiceInitiator; +import org.hibernate.engine.jdbc.cursor.spi.RefCursorSupport; import org.hibernate.service.spi.ServiceRegistryImplementor; /** * @author Steve Ebersole */ -public class RefCursorSupportInitiator implements BasicServiceInitiator { +public class RefCursorSupportInitiator implements StandardServiceInitiator { public static final RefCursorSupportInitiator INSTANCE = new RefCursorSupportInitiator(); @Override diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/internal/StandardRefCursorSupport.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/StandardRefCursorSupport.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/internal/StandardRefCursorSupport.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/StandardRefCursorSupport.java index cb48b29468..93f3e6a9de 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/internal/StandardRefCursorSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/StandardRefCursorSupport.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.cursor.internal; +package org.hibernate.engine.jdbc.cursor.internal; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -35,7 +35,7 @@ import org.jboss.logging.Logger; import org.hibernate.HibernateException; import org.hibernate.engine.jdbc.spi.JdbcServices; -import org.hibernate.service.jdbc.cursor.spi.RefCursorSupport; +import org.hibernate.engine.jdbc.cursor.spi.RefCursorSupport; import org.hibernate.service.spi.InjectService; /** diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/spi/RefCursorSupport.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/spi/RefCursorSupport.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/spi/RefCursorSupport.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/spi/RefCursorSupport.java index 75babaaba8..7785f0954f 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/spi/RefCursorSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/spi/RefCursorSupport.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.cursor.spi; +package org.hibernate.engine.jdbc.cursor.spi; import java.sql.CallableStatement; import java.sql.ResultSet; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/AbstractDialectResolver.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/AbstractDialectResolver.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/AbstractDialectResolver.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/AbstractDialectResolver.java index 4eab076eed..0d50ba37cf 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/AbstractDialectResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/AbstractDialectResolver.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.dialect.internal; +package org.hibernate.engine.jdbc.dialect.internal; import java.sql.DatabaseMetaData; import java.sql.SQLException; @@ -33,7 +33,7 @@ import org.hibernate.dialect.Dialect; import org.hibernate.dialect.resolver.BasicSQLExceptionConverter; import org.hibernate.exception.JDBCConnectionException; import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.service.jdbc.dialect.spi.DialectResolver; +import org.hibernate.engine.jdbc.dialect.spi.DialectResolver; /** * A templated resolver impl which delegates to the {@link #resolveDialectInternal} method diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/BasicDialectResolver.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/BasicDialectResolver.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/BasicDialectResolver.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/BasicDialectResolver.java index 0de006258e..79cd856ef3 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/BasicDialectResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/BasicDialectResolver.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.dialect.internal; +package org.hibernate.engine.jdbc.dialect.internal; import java.sql.DatabaseMetaData; import java.sql.SQLException; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java similarity index 92% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectFactoryImpl.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java index 7c045603c9..a140f381b5 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.dialect.internal; +package org.hibernate.engine.jdbc.dialect.internal; import java.sql.Connection; import java.sql.DatabaseMetaData; @@ -31,10 +31,10 @@ import java.util.Map; import org.hibernate.HibernateException; import org.hibernate.cfg.AvailableSettings; import org.hibernate.dialect.Dialect; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.classloading.spi.ClassLoadingException; -import org.hibernate.service.jdbc.dialect.spi.DialectFactory; -import org.hibernate.service.jdbc.dialect.spi.DialectResolver; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; +import org.hibernate.engine.jdbc.dialect.spi.DialectFactory; +import org.hibernate.engine.jdbc.dialect.spi.DialectResolver; import org.hibernate.service.spi.InjectService; /** diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryInitiator.java similarity index 85% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectFactoryInitiator.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryInitiator.java index 0f2d7a3f05..a207465656 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryInitiator.java @@ -21,12 +21,12 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.dialect.internal; +package org.hibernate.engine.jdbc.dialect.internal; import java.util.Map; -import org.hibernate.service.jdbc.dialect.spi.DialectFactory; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.StandardServiceInitiator; +import org.hibernate.engine.jdbc.dialect.spi.DialectFactory; import org.hibernate.service.spi.ServiceRegistryImplementor; /** @@ -34,7 +34,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor; * * @author Steve Ebersole */ -public class DialectFactoryInitiator implements BasicServiceInitiator { +public class DialectFactoryInitiator implements StandardServiceInitiator { public static final DialectFactoryInitiator INSTANCE = new DialectFactoryInitiator(); @Override diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectResolverInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverInitiator.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectResolverInitiator.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverInitiator.java index aba44b5bad..bd48a88630 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectResolverInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverInitiator.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.dialect.internal; +package org.hibernate.engine.jdbc.dialect.internal; import java.util.ArrayList; import java.util.List; @@ -30,9 +30,9 @@ import java.util.Map; import org.hibernate.HibernateException; import org.hibernate.cfg.AvailableSettings; import org.hibernate.internal.util.StringHelper; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.jdbc.dialect.spi.DialectResolver; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.engine.jdbc.dialect.spi.DialectResolver; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.service.spi.ServiceException; import org.hibernate.service.spi.ServiceRegistryImplementor; @@ -41,7 +41,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor; * * @author Steve Ebersole */ -public class DialectResolverInitiator implements BasicServiceInitiator { +public class DialectResolverInitiator implements StandardServiceInitiator { public static final DialectResolverInitiator INSTANCE = new DialectResolverInitiator(); @Override diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectResolverSet.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverSet.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectResolverSet.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverSet.java index 8577d8cc1d..ed11ab2c5d 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectResolverSet.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverSet.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.dialect.internal; +package org.hibernate.engine.jdbc.dialect.internal; import java.sql.DatabaseMetaData; import java.util.ArrayList; @@ -33,7 +33,7 @@ import org.jboss.logging.Logger; import org.hibernate.dialect.Dialect; import org.hibernate.exception.JDBCConnectionException; import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.service.jdbc.dialect.spi.DialectResolver; +import org.hibernate.engine.jdbc.dialect.spi.DialectResolver; /** * A {@link DialectResolver} implementation which coordinates resolution by delegating to sub-resolvers. diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/StandardDialectResolver.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolver.java similarity index 99% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/StandardDialectResolver.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolver.java index 3e6c4dba52..f26633f1ea 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/StandardDialectResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolver.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.dialect.internal; +package org.hibernate.engine.jdbc.dialect.internal; import java.sql.DatabaseMetaData; import java.sql.SQLException; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/spi/DialectFactory.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectFactory.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/spi/DialectFactory.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectFactory.java index 33e9c1dcad..876666d6da 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/spi/DialectFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectFactory.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.dialect.spi; +package org.hibernate.engine.jdbc.dialect.spi; import java.sql.Connection; import java.util.Map; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/spi/DialectResolver.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectResolver.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/spi/DialectResolver.java rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectResolver.java index 1adfae2ecf..67ef46b4b2 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/spi/DialectResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectResolver.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jdbc.dialect.spi; +package org.hibernate.engine.jdbc.dialect.spi; import java.sql.DatabaseMetaData; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesImpl.java index 2b1c58ff02..3ded537eb0 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesImpl.java @@ -55,10 +55,10 @@ import org.hibernate.exception.spi.SQLExceptionConverter; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.config.ConfigurationHelper; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider; -import org.hibernate.service.jdbc.cursor.internal.StandardRefCursorSupport; -import org.hibernate.service.jdbc.dialect.spi.DialectFactory; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider; +import org.hibernate.engine.jdbc.cursor.internal.StandardRefCursorSupport; +import org.hibernate.engine.jdbc.dialect.spi.DialectFactory; import org.hibernate.service.spi.Configurable; import org.hibernate.service.spi.ServiceRegistryAwareService; import org.hibernate.service.spi.ServiceRegistryImplementor; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesInitiator.java index c404917a30..a1704b075a 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesInitiator.java @@ -25,8 +25,8 @@ package org.hibernate.engine.jdbc.internal; import java.util.Map; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.engine.jdbc.spi.JdbcServices; -import org.hibernate.service.spi.BasicServiceInitiator; import org.hibernate.service.spi.ServiceRegistryImplementor; /** @@ -36,7 +36,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor; * * @author Steve Ebersole */ -public class JdbcServicesInitiator implements BasicServiceInitiator { +public class JdbcServicesInitiator implements StandardServiceInitiator { public static final JdbcServicesInitiator INSTANCE = new JdbcServicesInitiator(); @Override diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/JdbcConnectionAccess.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/JdbcConnectionAccess.java index 7256322d77..cb19212967 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/JdbcConnectionAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/JdbcConnectionAccess.java @@ -56,8 +56,8 @@ public interface JdbcConnectionAccess extends Serializable { * Does the underlying provider of connections support aggressive releasing of connections (and re-acquisition * of those connections later, if need be) in JTA environments? * - * @see org.hibernate.service.jdbc.connections.spi.ConnectionProvider#supportsAggressiveRelease() - * @see org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider#supportsAggressiveRelease() + * @see org.hibernate.engine.jdbc.connections.spi.ConnectionProvider#supportsAggressiveRelease() + * @see org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider#supportsAggressiveRelease() */ public boolean supportsAggressiveRelease(); } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/JdbcServices.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/JdbcServices.java index 3ff092d19e..1580733fcb 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/JdbcServices.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/JdbcServices.java @@ -29,7 +29,7 @@ import org.hibernate.dialect.Dialect; import org.hibernate.engine.jdbc.LobCreationContext; import org.hibernate.engine.jdbc.LobCreator; import org.hibernate.service.Service; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; /** * Contract for services around JDBC operations. These represent shared resources, aka not varied by session/use. diff --git a/hibernate-core/src/main/java/org/hibernate/service/jndi/JndiException.java b/hibernate-core/src/main/java/org/hibernate/engine/jndi/JndiException.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/service/jndi/JndiException.java rename to hibernate-core/src/main/java/org/hibernate/engine/jndi/JndiException.java index 13431d4a7a..b7047ddbc1 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jndi/JndiException.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jndi/JndiException.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jndi; +package org.hibernate.engine.jndi; import org.hibernate.HibernateException; /** diff --git a/hibernate-core/src/main/java/org/hibernate/service/jndi/JndiNameException.java b/hibernate-core/src/main/java/org/hibernate/engine/jndi/JndiNameException.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/service/jndi/JndiNameException.java rename to hibernate-core/src/main/java/org/hibernate/engine/jndi/JndiNameException.java index 526a18276c..6114c6dbfa 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jndi/JndiNameException.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jndi/JndiNameException.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jndi; +package org.hibernate.engine.jndi; import org.hibernate.HibernateException; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jndi/internal/JndiServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/service/jndi/internal/JndiServiceImpl.java rename to hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java index d149f2ce67..86a0882450 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jndi/internal/JndiServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jndi.internal; +package org.hibernate.engine.jndi.internal; import java.util.Hashtable; import java.util.Map; @@ -38,9 +38,9 @@ import org.jboss.logging.Logger; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.jndi.JndiHelper; -import org.hibernate.service.jndi.JndiException; -import org.hibernate.service.jndi.JndiNameException; -import org.hibernate.service.jndi.spi.JndiService; +import org.hibernate.engine.jndi.JndiException; +import org.hibernate.engine.jndi.JndiNameException; +import org.hibernate.engine.jndi.spi.JndiService; /** * Standard implementation of JNDI services. diff --git a/hibernate-core/src/main/java/org/hibernate/service/jndi/internal/JndiServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceInitiator.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/service/jndi/internal/JndiServiceInitiator.java rename to hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceInitiator.java index 5cd32042bb..3280c04b26 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jndi/internal/JndiServiceInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceInitiator.java @@ -21,12 +21,12 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jndi.internal; +package org.hibernate.engine.jndi.internal; import java.util.Map; -import org.hibernate.service.jndi.spi.JndiService; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.engine.jndi.spi.JndiService; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.service.spi.ServiceRegistryImplementor; /** @@ -34,7 +34,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor; * * @author Steve Ebersole */ -public class JndiServiceInitiator implements BasicServiceInitiator { +public class JndiServiceInitiator implements StandardServiceInitiator { public static final JndiServiceInitiator INSTANCE = new JndiServiceInitiator(); @Override diff --git a/hibernate-core/src/main/java/org/hibernate/service/jndi/spi/JndiService.java b/hibernate-core/src/main/java/org/hibernate/engine/jndi/spi/JndiService.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/jndi/spi/JndiService.java rename to hibernate-core/src/main/java/org/hibernate/engine/jndi/spi/JndiService.java index 3e01849149..95905dd720 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jndi/spi/JndiService.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jndi/spi/JndiService.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jndi.spi; +package org.hibernate.engine.jndi.spi; import javax.naming.event.NamespaceChangeListener; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java index 7922d2bc99..d86f6e4cf2 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java @@ -51,7 +51,7 @@ import org.hibernate.id.IdentifierGenerator; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.proxy.EntityNotFoundDelegate; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.stat.spi.StatisticsImplementor; import org.hibernate.type.Type; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionCoordinatorImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionCoordinatorImpl.java index 2324686ab9..4fc91f54ed 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionCoordinatorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionCoordinatorImpl.java @@ -51,7 +51,7 @@ import org.hibernate.engine.transaction.synchronization.internal.Synchronization import org.hibernate.engine.transaction.synchronization.spi.SynchronizationCallbackCoordinator; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.collections.CollectionHelper; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; /** * Standard implementation of the Hibernate {@link TransactionCoordinator} diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionFactoryInitiator.java index 2f153e75f0..5cee1c627f 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionFactoryInitiator.java @@ -32,8 +32,8 @@ import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory; import org.hibernate.engine.transaction.spi.TransactionFactory; import org.hibernate.engine.transaction.spi.TransactionImplementor; import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.service.selector.spi.StrategySelector; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.selector.spi.StrategySelector; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.service.spi.ServiceRegistryImplementor; /** @@ -42,7 +42,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor; * @author Steve Ebersole */ public class TransactionFactoryInitiator - implements BasicServiceInitiator { + implements StandardServiceInitiator { private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/jta/JtaTransactionFactory.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/jta/JtaTransactionFactory.java index 539a800040..f0e50881b9 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/jta/JtaTransactionFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/jta/JtaTransactionFactory.java @@ -30,7 +30,7 @@ import org.hibernate.ConnectionReleaseMode; import org.hibernate.TransactionException; import org.hibernate.engine.transaction.spi.TransactionCoordinator; import org.hibernate.engine.transaction.spi.TransactionFactory; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; /** * Factory for {@link JtaTransaction} instances. diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/AbstractJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/AbstractJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java index c05e261b3d..fc997d6551 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/AbstractJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import java.util.Map; import javax.transaction.Synchronization; @@ -33,8 +33,8 @@ import javax.transaction.UserTransaction; import org.hibernate.cfg.AvailableSettings; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.jndi.spi.JndiService; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.jndi.spi.JndiService; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.service.spi.Configurable; import org.hibernate.service.spi.ServiceRegistryAwareService; import org.hibernate.service.spi.ServiceRegistryImplementor; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/BitronixJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/BitronixJtaPlatform.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/BitronixJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/BitronixJtaPlatform.java index 17b2505c76..e6f5f925f9 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/BitronixJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/BitronixJtaPlatform.java @@ -21,14 +21,14 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import java.lang.reflect.Method; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.jta.platform.spi.JtaPlatformException; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/BorlandEnterpriseServerJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/BorlandEnterpriseServerJtaPlatform.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/BorlandEnterpriseServerJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/BorlandEnterpriseServerJtaPlatform.java index 9144f8e113..49390a89d0 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/BorlandEnterpriseServerJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/BorlandEnterpriseServerJtaPlatform.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JBossAppServerJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java similarity index 94% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JBossAppServerJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java index 92bef427a8..4ef9cf6f21 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JBossAppServerJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java @@ -21,12 +21,12 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; -import org.hibernate.service.jndi.JndiException; +import org.hibernate.engine.jndi.JndiException; /** * JtaPlatform definition for JBoss Application Server. diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JBossStandAloneJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossStandAloneJtaPlatform.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JBossStandAloneJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossStandAloneJtaPlatform.java index 85f9861fd9..9ad1d0b871 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JBossStandAloneJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossStandAloneJtaPlatform.java @@ -21,13 +21,13 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.jta.platform.spi.JtaPlatformException; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException; /** * Return a standalone JTA transaction manager for JBoss Transactions diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JOTMJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JOTMJtaPlatform.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JOTMJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JOTMJtaPlatform.java index 9de4f7bc54..255d2bfb83 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JOTMJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JOTMJtaPlatform.java @@ -21,14 +21,14 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import java.lang.reflect.Method; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.jta.platform.spi.JtaPlatformException; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JOnASJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JOnASJtaPlatform.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JOnASJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JOnASJtaPlatform.java index b02c6b9218..7c2d16ca04 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JOnASJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JOnASJtaPlatform.java @@ -21,13 +21,13 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import java.lang.reflect.Method; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; -import org.hibernate.service.jta.platform.spi.JtaPlatformException; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException; /** * JTA platform implementation for JOnAS diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JRun4JtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JRun4JtaPlatform.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JRun4JtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JRun4JtaPlatform.java index 2242bcdbb3..a23d78a018 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JRun4JtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JRun4JtaPlatform.java @@ -21,13 +21,13 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; /** - * {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation for JRun4 AS + * {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation for JRun4 AS * * @author Joseph Bissen * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JtaPlatformInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JtaPlatformInitiator.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java index 5c7fb6d5cc..d5439a21aa 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JtaPlatformInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java @@ -21,30 +21,30 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import java.util.Map; import org.jboss.logging.Logger; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Environment; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.jndi.JndiHelper; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.config.spi.ConfigurationService; -import org.hibernate.service.jta.platform.spi.JtaPlatform; -import org.hibernate.service.jta.platform.spi.JtaPlatformException; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.engine.config.spi.ConfigurationService; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.transaction.TransactionManagerLookup; /** - * Standard initiator for the standard {@link org.hibernate.service.jta.platform.spi.JtaPlatform} + * Standard initiator for the standard {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} * * @author Steve Ebersole */ -public class JtaPlatformInitiator implements BasicServiceInitiator { +public class JtaPlatformInitiator implements StandardServiceInitiator { public static final JtaPlatformInitiator INSTANCE = new JtaPlatformInitiator(); private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, JtaPlatformInitiator.class.getName()); diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JtaSynchronizationStrategy.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaSynchronizationStrategy.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JtaSynchronizationStrategy.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaSynchronizationStrategy.java index f33e461347..d296f0d603 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JtaSynchronizationStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaSynchronizationStrategy.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import java.io.Serializable; import javax.transaction.Synchronization; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/NoJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/NoJtaPlatform.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/NoJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/NoJtaPlatform.java index 440674b07b..26c3235c75 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/NoJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/NoJtaPlatform.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import javax.transaction.Status; import javax.transaction.Synchronization; @@ -30,7 +30,7 @@ import javax.transaction.Transaction; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; /** * The non-configured form of JTA platform. This is what is used if none was set up. diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/OC4JJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/OC4JJtaPlatform.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/OC4JJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/OC4JJtaPlatform.java index c21c9c6019..3bdcbdfe96 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/OC4JJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/OC4JJtaPlatform.java @@ -21,13 +21,13 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; /** - * {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation for the OC4J (Oracle) AS. + * {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation for the OC4J (Oracle) AS. * * @author Stijn Janssens * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/OrionJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/OrionJtaPlatform.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/OrionJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/OrionJtaPlatform.java index 40028e9539..0e9566d600 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/OrionJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/OrionJtaPlatform.java @@ -21,13 +21,13 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; /** - * {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation for Orion + * {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation for Orion * * @author Gavin King * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/ResinJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/ResinJtaPlatform.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/ResinJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/ResinJtaPlatform.java index b2ad76130e..eaed24a3f9 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/ResinJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/ResinJtaPlatform.java @@ -21,13 +21,13 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; /** - * {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation for Resin + * {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation for Resin * * @author Aapo Laakkonen * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SunOneJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SunOneJtaPlatform.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SunOneJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SunOneJtaPlatform.java index bd962698ec..fd6ebc98ac 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SunOneJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SunOneJtaPlatform.java @@ -21,13 +21,13 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; /** - * {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation for Sun ONE Application Server 7 and above + * {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation for Sun ONE Application Server 7 and above * * @author Robert Davidson * @author Sanjeev Krishnan diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SynchronizationRegistryAccess.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SynchronizationRegistryAccess.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SynchronizationRegistryAccess.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SynchronizationRegistryAccess.java index 9b4c1d400a..bab04fa19c 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SynchronizationRegistryAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SynchronizationRegistryAccess.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import java.io.Serializable; import javax.transaction.TransactionSynchronizationRegistry; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SynchronizationRegistryBasedSynchronizationStrategy.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SynchronizationRegistryBasedSynchronizationStrategy.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SynchronizationRegistryBasedSynchronizationStrategy.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SynchronizationRegistryBasedSynchronizationStrategy.java index d8af05e484..d4b08df264 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SynchronizationRegistryBasedSynchronizationStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SynchronizationRegistryBasedSynchronizationStrategy.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import javax.transaction.Synchronization; import javax.transaction.TransactionSynchronizationRegistry; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerAccess.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerAccess.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerAccess.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerAccess.java index ee4c8ec53a..26c7411743 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerAccess.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import java.io.Serializable; import javax.transaction.TransactionManager; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerBasedSynchronizationStrategy.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerBasedSynchronizationStrategy.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerBasedSynchronizationStrategy.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerBasedSynchronizationStrategy.java index 070fb52ffb..b9e3614138 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerBasedSynchronizationStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerBasedSynchronizationStrategy.java @@ -21,12 +21,12 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import javax.transaction.Synchronization; import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper; -import org.hibernate.service.jta.platform.spi.JtaPlatformException; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException; /** * Implementation of the {@link JtaSynchronizationStrategy} contract based on using a diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerLookupBridge.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerLookupBridge.java similarity index 94% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerLookupBridge.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerLookupBridge.java index bd3889ce99..7664dd6e5b 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerLookupBridge.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerLookupBridge.java @@ -21,14 +21,14 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import java.util.Properties; import javax.transaction.Transaction; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; -import org.hibernate.service.jndi.spi.JndiService; +import org.hibernate.engine.jndi.spi.JndiService; import org.hibernate.transaction.TransactionManagerLookup; /** diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WebSphereExtendedJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereExtendedJtaPlatform.java similarity index 99% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WebSphereExtendedJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereExtendedJtaPlatform.java index ec2e971bae..19a81bdde7 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WebSphereExtendedJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereExtendedJtaPlatform.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WebSphereJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereJtaPlatform.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WebSphereJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereJtaPlatform.java index 1f8c758f9a..9113045d87 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WebSphereJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereJtaPlatform.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import java.lang.reflect.Method; import javax.transaction.TransactionManager; @@ -30,7 +30,7 @@ import javax.transaction.UserTransaction; import org.jboss.logging.Logger; import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.service.jta.platform.spi.JtaPlatformException; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException; /** * JTA platform implementation for WebSphere (versions 4, 5.0 and 5.1) diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WeblogicJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WeblogicJtaPlatform.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WeblogicJtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WeblogicJtaPlatform.java index 26bc3a69f5..54c82f8ac1 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WeblogicJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WeblogicJtaPlatform.java @@ -21,13 +21,13 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.internal; +package org.hibernate.engine.transaction.jta.platform.internal; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; /** - * {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation for Weblogic + * {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation for Weblogic * * @author Gavin King * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/spi/JtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatform.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/spi/JtaPlatform.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatform.java index 86c56bc843..1bf027f9d3 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/spi/JtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatform.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.spi; +package org.hibernate.engine.transaction.jta.platform.spi; import javax.transaction.Synchronization; import javax.transaction.SystemException; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/spi/JtaPlatformException.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatformException.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/spi/JtaPlatformException.java rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatformException.java index abc7f31d79..28fc1b45da 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/spi/JtaPlatformException.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatformException.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jta.platform.spi; +package org.hibernate.engine.transaction.jta.platform.spi; import org.hibernate.HibernateException; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/AbstractTransactionImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/AbstractTransactionImpl.java index 22463d4282..a1e8cf2bcd 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/AbstractTransactionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/AbstractTransactionImpl.java @@ -31,7 +31,7 @@ import org.jboss.logging.Logger; import org.hibernate.HibernateException; import org.hibernate.TransactionException; import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; /** * Abstract support for creating {@link TransactionImplementor transaction} implementations @@ -98,7 +98,7 @@ public abstract class AbstractTransactionImpl implements TransactionImplementor /** * Provide subclasses with convenient access to the configured {@link JtaPlatform} * - * @return The {@link org.hibernate.service.jta.platform.spi.JtaPlatform} + * @return The {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} */ protected JtaPlatform jtaPlatform() { return transactionCoordinator().getTransactionContext().getTransactionEnvironment().getJtaPlatform(); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/TransactionEnvironment.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/TransactionEnvironment.java index 65a5f5c622..e3e9e19f5a 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/TransactionEnvironment.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/TransactionEnvironment.java @@ -25,7 +25,7 @@ package org.hibernate.engine.transaction.spi; import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.stat.spi.StatisticsImplementor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/id/factory/internal/MutableIdentifierGeneratorFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/id/factory/internal/MutableIdentifierGeneratorFactoryInitiator.java index 92808e6379..868902fb29 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/factory/internal/MutableIdentifierGeneratorFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/factory/internal/MutableIdentifierGeneratorFactoryInitiator.java @@ -2,14 +2,14 @@ package org.hibernate.id.factory.internal; import java.util.Map; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory; -import org.hibernate.service.spi.BasicServiceInitiator; import org.hibernate.service.spi.ServiceRegistryImplementor; /** * @author Emmanuel Bernard */ -public class MutableIdentifierGeneratorFactoryInitiator implements BasicServiceInitiator { +public class MutableIdentifierGeneratorFactoryInitiator implements StandardServiceInitiator { public static final MutableIdentifierGeneratorFactoryInitiator INSTANCE = new MutableIdentifierGeneratorFactoryInitiator(); @Override diff --git a/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java index 4ffa634769..b4cd7872d7 100644 --- a/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java @@ -30,7 +30,7 @@ import org.jboss.logging.Logger; import org.hibernate.cfg.beanvalidation.BeanValidationIntegrator; import org.hibernate.integrator.spi.Integrator; import org.hibernate.integrator.spi.IntegratorService; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/integrator/spi/ServiceContributingIntegrator.java b/hibernate-core/src/main/java/org/hibernate/integrator/spi/ServiceContributingIntegrator.java index 94154ef952..ccb136bb12 100644 --- a/hibernate-core/src/main/java/org/hibernate/integrator/spi/ServiceContributingIntegrator.java +++ b/hibernate-core/src/main/java/org/hibernate/integrator/spi/ServiceContributingIntegrator.java @@ -23,7 +23,7 @@ */ package org.hibernate.integrator.spi; -import org.hibernate.service.ServiceRegistryBuilder; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; /** * Additional, optional contract for Integrators that wish to contribute {@link org.hibernate.service.Service services} @@ -38,5 +38,5 @@ public interface ServiceContributingIntegrator extends Integrator { * * @param serviceRegistryBuilder The build to prepare. */ - public void prepareServices(ServiceRegistryBuilder serviceRegistryBuilder); + public void prepareServices(StandardServiceRegistryBuilder serviceRegistryBuilder); } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSessionImpl.java index 51bf9caabd..8b51b21036 100755 --- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSessionImpl.java @@ -55,8 +55,8 @@ import org.hibernate.engine.transaction.spi.TransactionEnvironment; import org.hibernate.jdbc.WorkExecutor; import org.hibernate.jdbc.WorkExecutorVisitable; import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider; import org.hibernate.type.Type; /** diff --git a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java index 4cc0fd0986..8f2daf2efc 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java @@ -52,9 +52,9 @@ import org.hibernate.engine.loading.internal.EntityLoadContext; import org.hibernate.engine.spi.CollectionKey; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.id.IntegralDataTypeHolder; -import org.hibernate.service.jdbc.dialect.internal.AbstractDialectResolver; -import org.hibernate.service.jndi.JndiException; -import org.hibernate.service.jndi.JndiNameException; +import org.hibernate.engine.jdbc.dialect.internal.AbstractDialectResolver; +import org.hibernate.engine.jndi.JndiException; +import org.hibernate.engine.jndi.JndiNameException; import org.hibernate.type.BasicType; import org.hibernate.type.SerializationException; import org.hibernate.type.Type; diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java index 1c444807a9..a4bad4c387 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java @@ -126,12 +126,12 @@ import org.hibernate.persister.entity.Queryable; import org.hibernate.persister.spi.PersisterFactory; import org.hibernate.proxy.EntityNotFoundDelegate; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.classloading.spi.ClassLoadingException; -import org.hibernate.service.config.spi.ConfigurationService; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.service.jndi.spi.JndiService; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; +import org.hibernate.engine.config.spi.ConfigurationService; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jndi.spi.JndiService; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.SessionFactoryServiceRegistry; import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory; @@ -163,7 +163,7 @@ import org.hibernate.type.TypeResolver; * and pooling under the covers. It is crucial that the class is not only thread * safe, but also highly concurrent. Synchronization must be used extremely sparingly. * - * @see org.hibernate.service.jdbc.connections.spi.ConnectionProvider + * @see org.hibernate.engine.jdbc.connections.spi.ConnectionProvider * @see org.hibernate.Session * @see org.hibernate.hql.spi.QueryTranslator * @see org.hibernate.persister.entity.EntityPersister diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryRegistry.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryRegistry.java index 41dcfdeb71..9cdfd99886 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryRegistry.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryRegistry.java @@ -36,9 +36,9 @@ import javax.naming.spi.ObjectFactory; import org.jboss.logging.Logger; import org.hibernate.SessionFactory; -import org.hibernate.service.jndi.JndiException; -import org.hibernate.service.jndi.JndiNameException; -import org.hibernate.service.jndi.spi.JndiService; +import org.hibernate.engine.jndi.JndiException; +import org.hibernate.engine.jndi.JndiNameException; +import org.hibernate.engine.jndi.spi.JndiService; /** * A registry of all {@link SessionFactory} instances for the same classloader as this class. diff --git a/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureCallImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureCallImpl.java index b56c2a549d..5f251dde38 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureCallImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureCallImpl.java @@ -54,7 +54,7 @@ import org.hibernate.engine.spi.QueryParameters; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.internal.util.StringHelper; import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.service.jdbc.cursor.spi.RefCursorSupport; +import org.hibernate.engine.jdbc.cursor.spi.RefCursorSupport; import org.hibernate.type.DateType; import org.hibernate.type.ProcedureParameterExtractionAware; import org.hibernate.type.Type; diff --git a/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureOutputsImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureOutputsImpl.java index 590b8b8c75..31e5e1f77f 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureOutputsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureOutputsImpl.java @@ -23,17 +23,14 @@ */ package org.hibernate.internal; -import javax.persistence.ParameterMode; import java.sql.CallableStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import org.hibernate.JDBCException; -import org.hibernate.StoredProcedureCall.StoredProcedureParameter; import org.hibernate.StoredProcedureOutputs; import org.hibernate.StoredProcedureResultSetReturn; import org.hibernate.StoredProcedureReturn; @@ -45,7 +42,7 @@ import org.hibernate.loader.custom.CustomLoader; import org.hibernate.loader.custom.CustomQuery; import org.hibernate.loader.custom.Return; import org.hibernate.loader.custom.sql.SQLQueryReturnProcessor; -import org.hibernate.service.jdbc.cursor.spi.RefCursorSupport; +import org.hibernate.engine.jdbc.cursor.spi.RefCursorSupport; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/internal/TransactionEnvironmentImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/TransactionEnvironmentImpl.java index e864ecfea5..e818e84e63 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/TransactionEnvironmentImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/TransactionEnvironmentImpl.java @@ -28,7 +28,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.transaction.spi.TransactionEnvironment; import org.hibernate.engine.transaction.spi.TransactionFactory; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.stat.spi.StatisticsImplementor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/ConfigHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/ConfigHelper.java index fe2da98d0e..e43aea33b0 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/ConfigHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/ConfigHelper.java @@ -40,7 +40,7 @@ import org.hibernate.internal.CoreMessageLogger; /** * A simple class to centralize logic needed to locate config files on the system. * - * @todo : Update usages to use {@link org.hibernate.service.classloading.spi.ClassLoaderService} + * @todo : Update usages to use {@link org.hibernate.boot.registry.classloading.spi.ClassLoaderService} * * @author Steve Ebersole */ diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/jndi/JndiHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/jndi/JndiHelper.java index fdc5191a94..a93b83df39 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/jndi/JndiHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/jndi/JndiHelper.java @@ -38,7 +38,7 @@ import org.hibernate.cfg.Environment; /** * Helper for dealing with JNDI. * - * @deprecated As JNDI access should get routed through {@link org.hibernate.service.jndi.spi.JndiService} + * @deprecated As JNDI access should get routed through {@link org.hibernate.engine.jndi.spi.JndiService} */ @Deprecated public final class JndiHelper { diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java b/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java index 99810fb517..666c1be0a9 100644 --- a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java +++ b/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java @@ -9,12 +9,12 @@ import org.jboss.logging.Logger; import org.hibernate.HibernateException; import org.hibernate.SessionFactory; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Environment; import org.hibernate.cfg.ExternalSessionFactoryConfig; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.jndi.JndiHelper; -import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.tool.hbm2ddl.SchemaExport; @@ -66,7 +66,7 @@ public class HibernateService extends ExternalSessionFactoryConfig implements Hi LOG.startingServiceAtJndiName( boundName ); LOG.serviceProperties( properties ); return buildConfiguration().buildSessionFactory( - new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry() + new StandardServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateServiceMBean.java b/hibernate-core/src/main/java/org/hibernate/jmx/HibernateServiceMBean.java index 2d2913d7a3..25db707ede 100644 --- a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateServiceMBean.java +++ b/hibernate-core/src/main/java/org/hibernate/jmx/HibernateServiceMBean.java @@ -134,14 +134,14 @@ public interface HibernateServiceMBean { public void setUserTransactionName(String utName); /** - * Get the name of the {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation to use. + * Get the name of the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation to use. * - * @return The name of the {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation to use. + * @return The name of the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation to use. */ public String getJtaPlatformName(); /** - * Sets the name of the {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation to use. + * Sets the name of the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation to use. * * @param name The implementation class name. */ diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java b/hibernate-core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java index 837aa39be0..974277ebee 100644 --- a/hibernate-core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java +++ b/hibernate-core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java @@ -53,7 +53,7 @@ import org.hibernate.internal.SessionFactoryRegistry; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.metadata.ClassMetadata; import org.hibernate.metadata.CollectionMetadata; -import org.hibernate.service.jndi.internal.JndiServiceImpl; +import org.hibernate.engine.jndi.internal.JndiServiceImpl; import org.hibernate.stat.Statistics; /** diff --git a/hibernate-core/src/main/java/org/hibernate/service/jmx/internal/DisabledJmxServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/jmx/internal/DisabledJmxServiceImpl.java similarity index 94% rename from hibernate-core/src/main/java/org/hibernate/service/jmx/internal/DisabledJmxServiceImpl.java rename to hibernate-core/src/main/java/org/hibernate/jmx/internal/DisabledJmxServiceImpl.java index d9a1efe228..943a9a6769 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jmx/internal/DisabledJmxServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/jmx/internal/DisabledJmxServiceImpl.java @@ -21,10 +21,10 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jmx.internal; +package org.hibernate.jmx.internal; import javax.management.ObjectName; -import org.hibernate.service.jmx.spi.JmxService; +import org.hibernate.jmx.spi.JmxService; import org.hibernate.service.spi.Manageable; /** diff --git a/hibernate-core/src/main/java/org/hibernate/service/jmx/internal/JmxServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceImpl.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/jmx/internal/JmxServiceImpl.java rename to hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceImpl.java index 4ba6ca1ba2..384f56e6ec 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jmx/internal/JmxServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceImpl.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jmx.internal; +package org.hibernate.jmx.internal; import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.Map; @@ -38,7 +38,7 @@ import org.hibernate.cfg.Environment; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.Service; -import org.hibernate.service.jmx.spi.JmxService; +import org.hibernate.jmx.spi.JmxService; import org.hibernate.service.spi.Manageable; import org.hibernate.service.spi.Stoppable; diff --git a/hibernate-core/src/main/java/org/hibernate/service/jmx/internal/JmxServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceInitiator.java similarity index 88% rename from hibernate-core/src/main/java/org/hibernate/service/jmx/internal/JmxServiceInitiator.java rename to hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceInitiator.java index 1d2cc97eb9..e3c7b51a45 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jmx/internal/JmxServiceInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceInitiator.java @@ -21,14 +21,14 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jmx.internal; +package org.hibernate.jmx.internal; import java.util.Map; import org.hibernate.cfg.AvailableSettings; import org.hibernate.internal.util.config.ConfigurationHelper; -import org.hibernate.service.jmx.spi.JmxService; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.jmx.spi.JmxService; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.service.spi.ServiceRegistryImplementor; /** @@ -36,7 +36,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor; * * @author Steve Ebersole */ -public class JmxServiceInitiator implements BasicServiceInitiator { +public class JmxServiceInitiator implements StandardServiceInitiator { public static final JmxServiceInitiator INSTANCE = new JmxServiceInitiator(); @Override diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/package.html b/hibernate-core/src/main/java/org/hibernate/jmx/package.html deleted file mode 100755 index 66827f9090..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/jmx/package.html +++ /dev/null @@ -1,14 +0,0 @@ - - - -

        - This package exposes a Hibernate instance via JMX. -

        -

        - HibernateService allows configuration and management - of the Hibernate runtime. StatisticsService - reports information that might be useful for performance - tuning. -

        - - diff --git a/hibernate-core/src/main/java/org/hibernate/service/jmx/spi/JmxService.java b/hibernate-core/src/main/java/org/hibernate/jmx/spi/JmxService.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/service/jmx/spi/JmxService.java rename to hibernate-core/src/main/java/org/hibernate/jmx/spi/JmxService.java index 629cf8faec..96a52d4730 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/jmx/spi/JmxService.java +++ b/hibernate-core/src/main/java/org/hibernate/jmx/spi/JmxService.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.jmx.spi; +package org.hibernate.jmx.spi; import javax.management.ObjectName; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/MetadataSources.java b/hibernate-core/src/main/java/org/hibernate/metamodel/MetadataSources.java index 24a46ffbf1..ba0b78e69c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/MetadataSources.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/MetadataSources.java @@ -51,7 +51,7 @@ import org.hibernate.metamodel.source.MappingNotFoundException; import org.hibernate.metamodel.source.internal.JaxbHelper; import org.hibernate.metamodel.source.internal.MetadataBuilderImpl; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/domain/JavaType.java b/hibernate-core/src/main/java/org/hibernate/metamodel/domain/JavaType.java index d6c6a0eeff..59c5639387 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/domain/JavaType.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/domain/JavaType.java @@ -24,7 +24,7 @@ package org.hibernate.metamodel.domain; import org.hibernate.internal.util.ValueHolder; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; /** * Models the naming of a Java type where we may not have access to that type's {@link Class} reference. Generally diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/domain/Type.java b/hibernate-core/src/main/java/org/hibernate/metamodel/domain/Type.java index dac9779b6a..58d0f9592a 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/domain/Type.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/domain/Type.java @@ -50,7 +50,7 @@ public interface Type { * * @return The {@link Class} reference * - * @throws org.hibernate.service.classloading.spi.ClassLoadingException Indicates the class reference + * @throws org.hibernate.boot.registry.classloading.spi.ClassLoadingException Indicates the class reference * could not be determined. Generally this is the case in reverse-engineering scenarios where the specified * domain model classes do not yet exist. */ diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/AnnotationBindingContextImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/AnnotationBindingContextImpl.java index b3aa93d03c..27642a5be2 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/AnnotationBindingContextImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/AnnotationBindingContextImpl.java @@ -40,7 +40,7 @@ import org.hibernate.metamodel.domain.Type; import org.hibernate.metamodel.source.MappingDefaults; import org.hibernate.metamodel.source.MetadataImplementor; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/AnnotationMetadataSourceProcessorImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/AnnotationMetadataSourceProcessorImpl.java index 5b4855d352..c945491589 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/AnnotationMetadataSourceProcessorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/AnnotationMetadataSourceProcessorImpl.java @@ -51,7 +51,7 @@ import org.hibernate.metamodel.source.annotations.xml.mocker.EntityMappingsMocke import org.hibernate.metamodel.source.binder.Binder; import org.hibernate.metamodel.source.binder.EntityHierarchy; import org.hibernate.metamodel.source.internal.MetadataImpl; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; /** * Main class responsible to creating and binding the Hibernate meta-model from annotations. diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/JandexHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/JandexHelper.java index 6f7eca24a6..fd527435b7 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/JandexHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/JandexHelper.java @@ -45,7 +45,7 @@ import org.jboss.jandex.Type; import org.hibernate.AssertionFailure; import org.hibernate.HibernateException; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; /** * Utility methods for working with the jandex annotation index. diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/IndexBuilder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/IndexBuilder.java index 6440ddf1b1..1266eb1ad4 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/IndexBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/IndexBuilder.java @@ -40,7 +40,7 @@ import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.StringHelper; import org.hibernate.metamodel.source.annotations.xml.filter.IndexedAnnotationFilter; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; /** * @author Strong Liu diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/MockHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/MockHelper.java index b8f15c67b6..c608100712 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/MockHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/MockHelper.java @@ -44,7 +44,7 @@ import org.hibernate.internal.jaxb.mapping.orm.JaxbCascadeType; import org.hibernate.internal.util.StringHelper; import org.hibernate.metamodel.source.annotations.JPADotNames; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; /** * @author Strong Liu diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/Helper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/Helper.java index a9c09233e4..e70ecf46cb 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/Helper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/Helper.java @@ -54,8 +54,8 @@ import org.hibernate.metamodel.source.binder.ExplicitHibernateTypeSource; import org.hibernate.metamodel.source.binder.MetaAttributeSource; import org.hibernate.metamodel.source.binder.RelationalValueSource; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.classloading.spi.ClassLoadingException; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HibernateMappingProcessor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HibernateMappingProcessor.java index 5769cb950a..b7a4644b3b 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HibernateMappingProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HibernateMappingProcessor.java @@ -44,8 +44,8 @@ import org.hibernate.metamodel.relational.AuxiliaryDatabaseObject; import org.hibernate.metamodel.relational.BasicAuxiliaryDatabaseObjectImpl; import org.hibernate.metamodel.source.MappingException; import org.hibernate.metamodel.source.MetadataImplementor; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.classloading.spi.ClassLoadingException; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.type.Type; /** diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/IdentifierGeneratorResolver.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/IdentifierGeneratorResolver.java index bec3410649..c40e936b2e 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/IdentifierGeneratorResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/IdentifierGeneratorResolver.java @@ -32,7 +32,7 @@ import org.hibernate.cfg.ObjectNameNormalizer; import org.hibernate.id.PersistentIdentifierGenerator; import org.hibernate.metamodel.binding.EntityBinding; import org.hibernate.metamodel.source.MetadataImplementor; -import org.hibernate.service.config.spi.ConfigurationService; +import org.hibernate.engine.config.spi.ConfigurationService; /** * @author Gail Badner diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/JaxbHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/JaxbHelper.java index f3aeefe48e..f1fdb0bf6d 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/JaxbHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/JaxbHelper.java @@ -57,7 +57,7 @@ import org.hibernate.internal.jaxb.mapping.orm.JaxbEntityMappings; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.source.MappingException; import org.hibernate.metamodel.source.XsdException; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; /** * Helper class for unmarshalling xml configuration using StAX and JAXB. diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/MetadataBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/MetadataBuilderImpl.java index 5e07de1e95..5af4980c7e 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/MetadataBuilderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/MetadataBuilderImpl.java @@ -34,7 +34,7 @@ import org.hibernate.metamodel.MetadataBuilder; import org.hibernate.metamodel.MetadataSourceProcessingOrder; import org.hibernate.metamodel.MetadataSources; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.config.spi.ConfigurationService; +import org.hibernate.engine.config.spi.ConfigurationService; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/MetadataImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/MetadataImpl.java index bf6baa9786..0e25b152ed 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/MetadataImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/MetadataImpl.java @@ -66,7 +66,7 @@ import org.hibernate.metamodel.source.annotations.AnnotationMetadataSourceProces import org.hibernate.metamodel.source.hbm.HbmMetadataSourceProcessorImpl; import org.hibernate.persister.spi.PersisterClassResolver; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.type.TypeResolver; /** diff --git a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterClassResolverInitiator.java b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterClassResolverInitiator.java index 0f5a9d71b7..95db7a0271 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterClassResolverInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterClassResolverInitiator.java @@ -25,16 +25,16 @@ package org.hibernate.persister.internal; import java.util.Map; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.persister.spi.PersisterClassResolver; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.service.spi.ServiceException; import org.hibernate.service.spi.ServiceRegistryImplementor; /** * @author Steve Ebersole */ -public class PersisterClassResolverInitiator implements BasicServiceInitiator { +public class PersisterClassResolverInitiator implements StandardServiceInitiator { public static final PersisterClassResolverInitiator INSTANCE = new PersisterClassResolverInitiator(); public static final String IMPL_NAME = "hibernate.persister.resolver"; diff --git a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryInitiator.java index 74227a9c60..2ad3ae3614 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryInitiator.java @@ -25,16 +25,16 @@ package org.hibernate.persister.internal; import java.util.Map; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.persister.spi.PersisterFactory; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.service.spi.ServiceException; import org.hibernate.service.spi.ServiceRegistryImplementor; /** * @author Steve Ebersole */ -public class PersisterFactoryInitiator implements BasicServiceInitiator { +public class PersisterFactoryInitiator implements StandardServiceInitiator { public static final PersisterFactoryInitiator INSTANCE = new PersisterFactoryInitiator(); public static final String IMPL_NAME = "hibernate.persister.factory"; diff --git a/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistry.java b/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistry.java index 9b0a74e24a..623b54e35d 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistry.java +++ b/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistry.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 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 Inc. @@ -24,10 +24,8 @@ package org.hibernate.service; /** - * Specialization of the {@link ServiceRegistry} contract mainly to make the - * {@link ServiceRegistryBuilder#ServiceRegistryBuilder(BootstrapServiceRegistry)} signature type-safe - * - * @author Steve Ebersole + * @deprecated Use {@link org.hibernate.boot.registry.BootstrapServiceRegistry} instead */ -public interface BootstrapServiceRegistry extends ServiceRegistry { +@Deprecated +public interface BootstrapServiceRegistry extends org.hibernate.boot.registry.BootstrapServiceRegistry { } diff --git a/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistryBuilder.java index 6c1107bb6b..5d707232dd 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistryBuilder.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 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 Inc. @@ -23,131 +23,51 @@ */ package org.hibernate.service; -import java.util.LinkedHashSet; - -import org.hibernate.integrator.internal.IntegratorServiceImpl; import org.hibernate.integrator.spi.Integrator; -import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl; -import org.hibernate.service.internal.BootstrapServiceRegistryImpl; -import org.hibernate.service.selector.internal.StrategySelectorBuilder; -import org.hibernate.service.selector.internal.StrategySelectorImpl; /** - * Builder for bootstrap {@link ServiceRegistry} instances. - * - * @author Steve Ebersole - * - * @see BootstrapServiceRegistryImpl - * @see ServiceRegistryBuilder#ServiceRegistryBuilder(BootstrapServiceRegistry) + * @deprecated Use {@link org.hibernate.boot.registry.BootstrapServiceRegistryBuilder} instead */ -public class BootstrapServiceRegistryBuilder { - private final LinkedHashSet providedIntegrators = new LinkedHashSet(); - private ClassLoader applicationClassLoader; - private ClassLoader resourcesClassLoader; - private ClassLoader hibernateClassLoader; - private ClassLoader environmentClassLoader; - - private StrategySelectorBuilder strategySelectorBuilder = new StrategySelectorBuilder(); - - /** - * Add an {@link Integrator} to be applied to the bootstrap registry. - * - * @param integrator The integrator to add. - * @return {@code this}, for method chaining - */ +@Deprecated +public class BootstrapServiceRegistryBuilder extends org.hibernate.boot.registry.BootstrapServiceRegistryBuilder { + @Override public BootstrapServiceRegistryBuilder with(Integrator integrator) { - providedIntegrators.add( integrator ); + super.with( integrator ); return this; } - /** - * Applies the specified {@link ClassLoader} as the application class loader for the bootstrap registry - * - * @param classLoader The class loader to use - * @return {@code this}, for method chaining - */ - @SuppressWarnings( {"UnusedDeclaration"}) + @Override public BootstrapServiceRegistryBuilder withApplicationClassLoader(ClassLoader classLoader) { - this.applicationClassLoader = classLoader; + super.withApplicationClassLoader( classLoader ); return this; } - /** - * Applies the specified {@link ClassLoader} as the resource class loader for the bootstrap registry - * - * @param classLoader The class loader to use - * @return {@code this}, for method chaining - */ - @SuppressWarnings( {"UnusedDeclaration"}) + @Override public BootstrapServiceRegistryBuilder withResourceClassLoader(ClassLoader classLoader) { - this.resourcesClassLoader = classLoader; + super.withResourceClassLoader( classLoader ); return this; } - /** - * Applies the specified {@link ClassLoader} as the Hibernate class loader for the bootstrap registry - * - * @param classLoader The class loader to use - * @return {@code this}, for method chaining - */ - @SuppressWarnings( {"UnusedDeclaration"}) + @Override public BootstrapServiceRegistryBuilder withHibernateClassLoader(ClassLoader classLoader) { - this.hibernateClassLoader = classLoader; + super.withHibernateClassLoader( classLoader ); return this; } - /** - * Applies the specified {@link ClassLoader} as the environment (or system) class loader for the bootstrap registry - * - * @param classLoader The class loader to use - * @return {@code this}, for method chaining - */ - @SuppressWarnings( {"UnusedDeclaration"}) + @Override public BootstrapServiceRegistryBuilder withEnvironmentClassLoader(ClassLoader classLoader) { - this.environmentClassLoader = classLoader; + super.withEnvironmentClassLoader( classLoader ); return this; } - /** - * Applies a named strategy implementation to the bootstrap registry - * - * @param strategy The strategy - * @param name The registered name - * @param implementation The strategy implementation Class - * - * @return {@code this}, for method chaining - * - * @see org.hibernate.service.selector.spi.StrategySelector#registerStrategyImplementor(Class, String, Class) - */ - @SuppressWarnings( {"UnusedDeclaration"}) + @Override public BootstrapServiceRegistryBuilder withStrategySelector(Class strategy, String name, Class implementation) { - this.strategySelectorBuilder.addCustomRegistration( strategy, name, implementation ); + super.withStrategySelector( strategy, name, implementation ); return this; } - /** - * Build the bootstrap registry. - * - * @return The built bootstrap registry - */ + @Override public BootstrapServiceRegistry build() { - final ClassLoaderServiceImpl classLoaderService = new ClassLoaderServiceImpl( - applicationClassLoader, - resourcesClassLoader, - hibernateClassLoader, - environmentClassLoader - ); - - final IntegratorServiceImpl integratorService = new IntegratorServiceImpl( - providedIntegrators, - classLoaderService - ); - - - return new BootstrapServiceRegistryImpl( - classLoaderService, - strategySelectorBuilder.buildSelector( classLoaderService ), - integratorService - ); + return (BootstrapServiceRegistry) super.build(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/service/ConfigLoader.java b/hibernate-core/src/main/java/org/hibernate/service/ConfigLoader.java index 43e04792db..30aed6570b 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/ConfigLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/service/ConfigLoader.java @@ -29,12 +29,13 @@ import java.util.Properties; import org.jboss.logging.Logger; +import org.hibernate.boot.registry.BootstrapServiceRegistry; import org.hibernate.internal.jaxb.Origin; import org.hibernate.internal.jaxb.SourceType; import org.hibernate.internal.jaxb.cfg.JaxbHibernateConfiguration; import org.hibernate.internal.util.ValueHolder; import org.hibernate.internal.util.config.ConfigurationException; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.service.internal.JaxbProcessor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistry.java b/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistry.java index 910f301a8f..87fba8c9af 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistry.java +++ b/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistry.java @@ -37,8 +37,8 @@ public interface ServiceRegistry { public ServiceRegistry getParentServiceRegistry(); /** - * Retrieve a service by role. If service is not found, but a {@link org.hibernate.service.spi.BasicServiceInitiator} is registered for - * this service role, the service will be initialized and returned. + * Retrieve a service by role. If service is not found, but a {@link org.hibernate.service.spi.ServiceInitiator} is + * registered for this service role, the service will be initialized and returned. *

        * NOTE: We cannot return {@code >} here because the service might come from the parent... * diff --git a/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistryBuilder.java index 3395938948..6d9c358aef 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistryBuilder.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 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 Inc. @@ -23,199 +23,67 @@ */ package org.hibernate.service; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.Properties; -import org.hibernate.cfg.Environment; -import org.hibernate.integrator.spi.Integrator; -import org.hibernate.integrator.spi.IntegratorService; -import org.hibernate.integrator.spi.ServiceContributingIntegrator; -import org.hibernate.internal.jaxb.cfg.JaxbHibernateConfiguration; -import org.hibernate.internal.util.config.ConfigurationHelper; -import org.hibernate.service.internal.BootstrapServiceRegistryImpl; -import org.hibernate.service.internal.ProvidedService; -import org.hibernate.service.internal.StandardServiceRegistryImpl; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.StandardServiceInitiator; /** - * Builder for standard {@link ServiceRegistry} instances. - * - * @author Steve Ebersole - * - * @see StandardServiceRegistryImpl - * @see BootstrapServiceRegistryBuilder + * @deprecated Use {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder} instead */ -public class ServiceRegistryBuilder { - public static final String DEFAULT_CFG_RESOURCE_NAME = "hibernate.cfg.xml"; - - private final Map settings; - private final List initiators = standardInitiatorList(); - private final List providedServices = new ArrayList(); - - private final BootstrapServiceRegistry bootstrapServiceRegistry; - private final ConfigLoader configLoader; - - /** - * Create a default builder - */ +@Deprecated +public class ServiceRegistryBuilder extends org.hibernate.boot.registry.StandardServiceRegistryBuilder { public ServiceRegistryBuilder() { - this( new BootstrapServiceRegistryImpl() ); + super(); //To change body of overridden methods use File | Settings | File Templates. } - /** - * Create a builder with the specified bootstrap services. - * - * @param bootstrapServiceRegistry Provided bootstrap registry to use. - */ public ServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry) { - this.settings = Environment.getProperties(); - this.bootstrapServiceRegistry = bootstrapServiceRegistry; - this.configLoader = new ConfigLoader( bootstrapServiceRegistry ); + super( bootstrapServiceRegistry ); //To change body of overridden methods use File | Settings | File Templates. } - /** - * Used from the {@link #initiators} variable initializer - * - * @return List of standard initiators - */ - private static List standardInitiatorList() { - final List initiators = new ArrayList(); - initiators.addAll( StandardServiceInitiators.LIST ); - return initiators; - } - - /** - * Read settings from a {@link Properties} file. Differs from {@link #configure()} and {@link #configure(String)} - * in that here we read a {@link Properties} file while for {@link #configure} we read the XML variant. - * - * @param resourceName The name by which to perform a resource look up for the properties file. - * - * @return this, for method chaining - * - * @see #configure() - * @see #configure(String) - */ - @SuppressWarnings( {"unchecked"}) + @Override public ServiceRegistryBuilder loadProperties(String resourceName) { - settings.putAll( configLoader.loadProperties( resourceName ) ); + super.loadProperties( resourceName ); return this; } - /** - * Read setting information from an XML file using the standard resource location - * - * @return this, for method chaining - * - * @see #DEFAULT_CFG_RESOURCE_NAME - * @see #configure(String) - * @see #loadProperties(String) - */ + @Override public ServiceRegistryBuilder configure() { - return configure( DEFAULT_CFG_RESOURCE_NAME ); + super.configure(); + return this; } - /** - * Read setting information from an XML file using the named resource location - * - * @param resourceName The named resource - * - * @return this, for method chaining - * - * @see #loadProperties(String) - */ - @SuppressWarnings( {"unchecked"}) + @Override public ServiceRegistryBuilder configure(String resourceName) { - JaxbHibernateConfiguration configurationElement = configLoader.loadConfigXmlResource( resourceName ); - for ( JaxbHibernateConfiguration.JaxbSessionFactory.JaxbProperty xmlProperty : configurationElement.getSessionFactory().getProperty() ) { - settings.put( xmlProperty.getName(), xmlProperty.getValue() ); - } - + super.configure( resourceName ); return this; } - /** - * Apply a setting value - * - * @param settingName The name of the setting - * @param value The value to use. - * - * @return this, for method chaining - */ - @SuppressWarnings( {"unchecked", "UnusedDeclaration"}) + @Override public ServiceRegistryBuilder applySetting(String settingName, Object value) { - settings.put( settingName, value ); + super.applySetting( settingName, value ); return this; } - /** - * Apply a groups of setting values - * - * @param settings The incoming settings to apply - * - * @return this, for method chaining - */ - @SuppressWarnings( {"unchecked", "UnusedDeclaration"}) + @Override public ServiceRegistryBuilder applySettings(Map settings) { - this.settings.putAll( settings ); + super.applySettings( settings ); return this; } - /** - * Adds a service initiator. - * - * @param initiator The initiator to be added - * - * @return this, for method chaining - */ - @SuppressWarnings( {"UnusedDeclaration"}) - public ServiceRegistryBuilder addInitiator(BasicServiceInitiator initiator) { - initiators.add( initiator ); + @Override + public ServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) { + super.addInitiator( initiator ); return this; } - /** - * Adds a user-provided service - * - * @param serviceRole The role of the service being added - * @param service The service implementation - * - * @return this, for method chaining - */ - @SuppressWarnings( {"unchecked"}) - public ServiceRegistryBuilder addService(final Class serviceRole, final Service service) { - providedServices.add( new ProvidedService( serviceRole, service ) ); + @Override + public ServiceRegistryBuilder addService(Class serviceRole, Service service) { + super.addService( serviceRole, service ); return this; } - /** - * Build the service registry accounting for all settings and service initiators and services. - * - * @return The built service registry - */ + @Override public ServiceRegistry buildServiceRegistry() { - Map settingsCopy = new HashMap(); - settingsCopy.putAll( settings ); - Environment.verifyProperties( settingsCopy ); - ConfigurationHelper.resolvePlaceHolders( settingsCopy ); - - for ( Integrator integrator : bootstrapServiceRegistry.getService( IntegratorService.class ).getIntegrators() ) { - if ( ServiceContributingIntegrator.class.isInstance( integrator ) ) { - ServiceContributingIntegrator.class.cast( integrator ).prepareServices( this ); - } - } - - return new StandardServiceRegistryImpl( bootstrapServiceRegistry, initiators, providedServices, settingsCopy ); - } - - /** - * Destroy a service registry. Applications should only destroy registries they have explicitly created. - * - * @param serviceRegistry The registry to be closed. - */ - public static void destroy(ServiceRegistry serviceRegistry) { - ( (StandardServiceRegistryImpl) serviceRegistry ).destroy(); + return super.buildServiceRegistry(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java b/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java index 8d630f0953..2ef6115e72 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java +++ b/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.cache.internal.RegionFactoryInitiator; import org.hibernate.engine.jdbc.batch.internal.BatchBuilderInitiator; import org.hibernate.engine.jdbc.internal.JdbcServicesInitiator; @@ -34,17 +35,16 @@ import org.hibernate.engine.transaction.internal.TransactionFactoryInitiator; import org.hibernate.id.factory.internal.MutableIdentifierGeneratorFactoryInitiator; import org.hibernate.persister.internal.PersisterClassResolverInitiator; import org.hibernate.persister.internal.PersisterFactoryInitiator; -import org.hibernate.service.config.internal.ConfigurationServiceInitiator; +import org.hibernate.engine.config.internal.ConfigurationServiceInitiator; import org.hibernate.service.internal.SessionFactoryServiceRegistryFactoryInitiator; -import org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator; -import org.hibernate.service.jdbc.connections.internal.MultiTenantConnectionProviderInitiator; -import org.hibernate.service.jdbc.cursor.internal.RefCursorSupportInitiator; -import org.hibernate.service.jdbc.dialect.internal.DialectFactoryInitiator; -import org.hibernate.service.jdbc.dialect.internal.DialectResolverInitiator; -import org.hibernate.service.jmx.internal.JmxServiceInitiator; -import org.hibernate.service.jndi.internal.JndiServiceInitiator; -import org.hibernate.service.jta.platform.internal.JtaPlatformInitiator; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator; +import org.hibernate.engine.jdbc.connections.internal.MultiTenantConnectionProviderInitiator; +import org.hibernate.engine.jdbc.cursor.internal.RefCursorSupportInitiator; +import org.hibernate.engine.jdbc.dialect.internal.DialectFactoryInitiator; +import org.hibernate.engine.jdbc.dialect.internal.DialectResolverInitiator; +import org.hibernate.jmx.internal.JmxServiceInitiator; +import org.hibernate.engine.jndi.internal.JndiServiceInitiator; +import org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator; import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractorInitiator; /** @@ -53,10 +53,10 @@ import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractorInitiator; * @author Steve Ebersole */ public class StandardServiceInitiators { - public static List LIST = buildStandardServiceInitiatorList(); + public static List LIST = buildStandardServiceInitiatorList(); - private static List buildStandardServiceInitiatorList() { - final List serviceInitiators = new ArrayList(); + private static List buildStandardServiceInitiatorList() { + final List serviceInitiators = new ArrayList(); serviceInitiators.add( ConfigurationServiceInitiator.INSTANCE ); serviceInitiators.add( ImportSqlCommandExtractorInitiator.INSTANCE ); diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java index dda22639b0..0b160a1636 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java @@ -32,11 +32,11 @@ import org.jboss.logging.Logger; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.collections.CollectionHelper; -import org.hibernate.service.BootstrapServiceRegistry; +import org.hibernate.boot.registry.BootstrapServiceRegistry; import org.hibernate.service.Service; import org.hibernate.service.ServiceRegistry; import org.hibernate.service.UnknownServiceException; -import org.hibernate.service.jmx.spi.JmxService; +import org.hibernate.jmx.spi.JmxService; import org.hibernate.service.spi.InjectService; import org.hibernate.service.spi.Manageable; import org.hibernate.service.spi.ServiceBinding; diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/JaxbProcessor.java b/hibernate-core/src/main/java/org/hibernate/service/internal/JaxbProcessor.java index baa1485f06..19b8e617d4 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/JaxbProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/JaxbProcessor.java @@ -57,7 +57,7 @@ import org.hibernate.internal.jaxb.cfg.JaxbHibernateConfiguration; import org.hibernate.internal.util.config.ConfigurationException; import org.hibernate.metamodel.source.MappingException; import org.hibernate.metamodel.source.XsdException; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryImpl.java index dc04d9f48c..ab12132940 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryImpl.java @@ -31,7 +31,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory; /** - * Acts as a {@link Service} in the {@link StandardServiceRegistryImpl} whose function is as a factory for + * Acts as a {@link Service} in the {@link org.hibernate.boot.registry.internal.StandardServiceRegistryImpl} whose function is as a factory for * {@link SessionFactoryServiceRegistryImpl} implementations. * * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryInitiator.java index 5cabc73b87..e935561682 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryInitiator.java @@ -25,14 +25,14 @@ package org.hibernate.service.internal; import java.util.Map; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory; /** * @author Steve Ebersole */ -public class SessionFactoryServiceRegistryFactoryInitiator implements BasicServiceInitiator { +public class SessionFactoryServiceRegistryFactoryInitiator implements StandardServiceInitiator { public static final SessionFactoryServiceRegistryFactoryInitiator INSTANCE = new SessionFactoryServiceRegistryFactoryInitiator(); @Override diff --git a/hibernate-core/src/main/java/org/hibernate/service/selector/package-info.java b/hibernate-core/src/main/java/org/hibernate/service/selector/package-info.java deleted file mode 100644 index 885cc72a2e..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/service/selector/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package org.hibernate.service.selector; \ No newline at end of file diff --git a/hibernate-core/src/main/java/org/hibernate/stat/internal/StatisticsInitiator.java b/hibernate-core/src/main/java/org/hibernate/stat/internal/StatisticsInitiator.java index 373f8600fb..e6b523f58a 100644 --- a/hibernate-core/src/main/java/org/hibernate/stat/internal/StatisticsInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/internal/StatisticsInitiator.java @@ -30,8 +30,8 @@ import org.hibernate.cfg.Configuration; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.metamodel.source.MetadataImplementor; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.config.spi.ConfigurationService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.SessionFactoryServiceInitiator; import org.hibernate.stat.spi.StatisticsFactory; diff --git a/hibernate-core/src/main/java/org/hibernate/stat/spi/StatisticsImplementor.java b/hibernate-core/src/main/java/org/hibernate/stat/spi/StatisticsImplementor.java index 985479b10a..4373587f80 100644 --- a/hibernate-core/src/main/java/org/hibernate/stat/spi/StatisticsImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/spi/StatisticsImplementor.java @@ -49,7 +49,7 @@ public interface StatisticsImplementor extends Statistics, Service { public void flush(); /** - * Callback about a connection being obtained from {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} + * Callback about a connection being obtained from {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} */ public void connect(); diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/ImportSqlCommandExtractorInitiator.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/ImportSqlCommandExtractorInitiator.java index 6ea13eef8f..7f6a75552d 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/ImportSqlCommandExtractorInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/ImportSqlCommandExtractorInitiator.java @@ -3,10 +3,10 @@ package org.hibernate.tool.hbm2ddl; import java.util.Map; import org.hibernate.HibernateException; +import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.cfg.Environment; import org.hibernate.internal.util.StringHelper; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.spi.BasicServiceInitiator; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.service.spi.ServiceRegistryImplementor; /** @@ -15,7 +15,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor; * * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) */ -public class ImportSqlCommandExtractorInitiator implements BasicServiceInitiator { +public class ImportSqlCommandExtractorInitiator implements StandardServiceInitiator { public static final ImportSqlCommandExtractorInitiator INSTANCE = new ImportSqlCommandExtractorInitiator(); public static final ImportSqlCommandExtractor DEFAULT_EXTRACTOR = new SingleLineSqlCommandExtractor(); diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java index 00391b6b16..411866f517 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java @@ -28,12 +28,12 @@ import java.sql.Connection; import java.sql.SQLException; import java.util.Properties; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Environment; import org.hibernate.engine.jdbc.spi.SqlExceptionHelper; import org.hibernate.internal.util.config.ConfigurationHelper; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.internal.StandardServiceRegistryImpl; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; /** * A {@link ConnectionHelper} implementation based on an internally @@ -62,7 +62,7 @@ class ManagedProviderConnectionHelper implements ConnectionHelper { private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) { Environment.verifyProperties( properties ); ConfigurationHelper.resolvePlaceHolders( properties ); - return (StandardServiceRegistryImpl) new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry(); + return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry(); } public Connection getConnection() throws SQLException { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java index f8ce45e5b2..2d25d7a380 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java @@ -42,6 +42,7 @@ import java.util.Properties; import org.jboss.logging.Logger; import org.hibernate.HibernateException; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; @@ -59,10 +60,9 @@ import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.metamodel.source.MetadataImplementor; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.config.spi.ConfigurationService; -import org.hibernate.service.internal.StandardServiceRegistryImpl; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.config.spi.ConfigurationService; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; /** * Commandline tool to export table schema to the database. This class may also be called from inside an application. @@ -504,7 +504,7 @@ public class SchemaExport { private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) { Environment.verifyProperties( properties ); ConfigurationHelper.resolvePlaceHolders( properties ); - return (StandardServiceRegistryImpl) new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry(); + return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry(); } public static void main(String[] args) { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java index 713370850d..451fae85bf 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java @@ -37,6 +37,7 @@ import org.jboss.logging.Logger; import org.hibernate.HibernateException; import org.hibernate.JDBCException; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.cfg.NamingStrategy; @@ -50,8 +51,7 @@ import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; /** * A commandline tool to update a database schema. May also be called from inside an application. @@ -110,7 +110,7 @@ public class SchemaUpdate { private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) { Environment.verifyProperties( properties ); ConfigurationHelper.resolvePlaceHolders( properties ); - return (StandardServiceRegistryImpl) new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry(); + return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry(); } public static void main(String[] args) { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java index af64cfa563..8a748cffdc 100755 --- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java @@ -31,6 +31,7 @@ import java.util.Properties; import org.jboss.logging.Logger; import org.hibernate.HibernateException; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.cfg.NamingStrategy; @@ -40,8 +41,7 @@ import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; /** * A commandline tool to update a database schema. May also be called from @@ -79,7 +79,7 @@ public class SchemaValidator { private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) { Environment.verifyProperties( properties ); ConfigurationHelper.resolvePlaceHolders( properties ); - return (StandardServiceRegistryImpl) new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry(); + return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry(); } public static void main(String[] args) { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.java index 8dd589ae43..b98f550629 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.java @@ -28,7 +28,7 @@ import java.sql.Connection; import java.sql.SQLException; import org.hibernate.engine.jdbc.spi.SqlExceptionHelper; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; /** * A {@link ConnectionHelper} implementation based on a provided diff --git a/hibernate-core/src/test/java/org/hibernate/connection/PropertiesTest.java b/hibernate-core/src/test/java/org/hibernate/connection/PropertiesTest.java index c1a0e70f7f..1ae674536b 100644 --- a/hibernate-core/src/test/java/org/hibernate/connection/PropertiesTest.java +++ b/hibernate-core/src/test/java/org/hibernate/connection/PropertiesTest.java @@ -27,7 +27,7 @@ import java.util.Properties; import org.junit.Assert; import org.junit.Test; -import org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator; +import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator; import org.hibernate.testing.junit4.BaseUnitTestCase; /** diff --git a/hibernate-core/src/test/java/org/hibernate/dialect/TestingDialects.java b/hibernate-core/src/test/java/org/hibernate/dialect/TestingDialects.java index dd440c5deb..8c7bb01edf 100644 --- a/hibernate-core/src/test/java/org/hibernate/dialect/TestingDialects.java +++ b/hibernate-core/src/test/java/org/hibernate/dialect/TestingDialects.java @@ -26,8 +26,8 @@ import java.sql.DatabaseMetaData; import java.sql.SQLException; import org.hibernate.HibernateException; -import org.hibernate.service.jdbc.dialect.internal.AbstractDialectResolver; -import org.hibernate.service.jdbc.dialect.internal.BasicDialectResolver; +import org.hibernate.engine.jdbc.dialect.internal.AbstractDialectResolver; +import org.hibernate.engine.jdbc.dialect.internal.BasicDialectResolver; /** * @author Steve Ebersole diff --git a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java index 4d763ff5a5..957392a496 100644 --- a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java @@ -55,12 +55,12 @@ import org.hibernate.dialect.SQLServerDialect; import org.hibernate.dialect.SybaseASE15Dialect; import org.hibernate.dialect.SybaseAnywhereDialect; import org.hibernate.dialect.TestingDialects; -import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl; -import org.hibernate.service.classloading.spi.ClassLoadingException; -import org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl; -import org.hibernate.service.jdbc.dialect.internal.DialectResolverSet; -import org.hibernate.service.jdbc.dialect.internal.StandardDialectResolver; -import org.hibernate.service.jdbc.dialect.spi.DialectResolver; +import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; +import org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl; +import org.hibernate.engine.jdbc.dialect.internal.DialectResolverSet; +import org.hibernate.engine.jdbc.dialect.internal.StandardDialectResolver; +import org.hibernate.engine.jdbc.dialect.spi.DialectResolver; import org.hibernate.testing.junit4.BaseUnitTestCase; import static org.junit.Assert.assertEquals; diff --git a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectResolverTest.java b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectResolverTest.java index ae774dcb61..ba49a7e109 100644 --- a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectResolverTest.java +++ b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectResolverTest.java @@ -30,9 +30,9 @@ import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Mocks; import org.hibernate.dialect.TestingDialects; import org.hibernate.exception.JDBCConnectionException; -import org.hibernate.service.jdbc.dialect.internal.BasicDialectResolver; -import org.hibernate.service.jdbc.dialect.internal.DialectResolverSet; -import org.hibernate.service.jdbc.dialect.spi.DialectResolver; +import org.hibernate.engine.jdbc.dialect.internal.BasicDialectResolver; +import org.hibernate.engine.jdbc.dialect.internal.DialectResolverSet; +import org.hibernate.engine.jdbc.dialect.spi.DialectResolver; import org.hibernate.testing.junit4.BaseUnitTestCase; import static org.junit.Assert.assertEquals; diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/binding/AbstractBasicBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/binding/AbstractBasicBindingTests.java index 9e9f26a82a..1fecfaeabd 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/binding/AbstractBasicBindingTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/binding/AbstractBasicBindingTests.java @@ -31,6 +31,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.domain.BasicType; import org.hibernate.metamodel.domain.SingularAttribute; @@ -40,8 +41,7 @@ import org.hibernate.metamodel.relational.SimpleValue; import org.hibernate.metamodel.source.MetadataImplementor; import org.hibernate.metamodel.source.internal.MetadataImpl; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.type.LongType; import org.hibernate.type.StringType; @@ -64,7 +64,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase { @Before public void setUp() { - serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry(); + serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().buildServiceRegistry(); } @After diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/binding/BasicCollectionBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/binding/BasicCollectionBindingTests.java index 80cc00ee6d..98b8e26dc3 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/binding/BasicCollectionBindingTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/binding/BasicCollectionBindingTests.java @@ -30,8 +30,8 @@ import org.junit.Test; import org.hibernate.metamodel.MetadataSourceProcessingOrder; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.source.internal.MetadataImpl; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.testing.junit4.BaseUnitTestCase; import static org.junit.Assert.assertEquals; @@ -46,7 +46,7 @@ public class BasicCollectionBindingTests extends BaseUnitTestCase { @Before public void setUp() { - serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry(); + serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().buildServiceRegistry(); } @After diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/binding/SimpleValueBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/binding/SimpleValueBindingTests.java index 2b62e8b585..bf7c6d177c 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/binding/SimpleValueBindingTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/binding/SimpleValueBindingTests.java @@ -36,7 +36,7 @@ import org.hibernate.metamodel.relational.Datatype; import org.hibernate.metamodel.relational.Schema; import org.hibernate.metamodel.relational.Size; import org.hibernate.metamodel.relational.Table; -import org.hibernate.service.classloading.spi.ClassLoadingException; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.testing.junit4.BaseUnitTestCase; import static org.junit.Assert.assertSame; diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/BaseAnnotationBindingTestCase.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/BaseAnnotationBindingTestCase.java index 5f9ed9dd90..09e8ccd094 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/BaseAnnotationBindingTestCase.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/BaseAnnotationBindingTestCase.java @@ -30,10 +30,11 @@ import org.junit.rules.MethodRule; import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.Statement; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.binding.EntityBinding; import org.hibernate.metamodel.source.internal.MetadataImpl; -import org.hibernate.service.ServiceRegistryBuilder; + import org.hibernate.testing.junit4.BaseUnitTestCase; /** @@ -99,7 +100,7 @@ public abstract class BaseAnnotationBindingTestCase extends BaseUnitTestCase { private void createBindings() { try { - sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); Resources resourcesAnnotation = origFrameworkMethod.getAnnotation( Resources.class ); if ( resourcesAnnotation != null ) { sources.getMetadataBuilder().with( resourcesAnnotation.cacheMode() ); diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/IdentifierGeneratorTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/IdentifierGeneratorTest.java index 12c87aa8b6..1e54fc4fa2 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/IdentifierGeneratorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/IdentifierGeneratorTest.java @@ -42,7 +42,7 @@ import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.binding.EntityBinding; import org.hibernate.metamodel.binding.EntityIdentifier; import org.hibernate.metamodel.source.MappingException; -import org.hibernate.service.ServiceRegistryBuilder; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; @@ -147,7 +147,7 @@ public class IdentifierGeneratorTest extends BaseAnnotationBindingTestCase { @Test public void testUndefinedGenerator() { try { - sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); sources.addAnnotatedClass( NamedGeneratorEntity.class ); sources.buildMetadata(); fail(); diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/MapsIdTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/MapsIdTest.java index f97e61ef67..810e552820 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/MapsIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/MapsIdTest.java @@ -32,9 +32,9 @@ import javax.persistence.OneToMany; import org.junit.Test; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.source.MappingException; -import org.hibernate.service.ServiceRegistryBuilder; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertTrue; @@ -72,7 +72,7 @@ public class MapsIdTest extends BaseAnnotationBindingTestCase { @Resources(annotatedClasses = DependentId.class) public void testMapsIsOnOneToManyThrowsException() { try { - sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); sources.addAnnotatedClass( DependentId.class ); sources.addAnnotatedClass( Dependent.class ); sources.addAnnotatedClass( Employee.class ); diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/global/FetchProfileBinderTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/global/FetchProfileBinderTest.java index 344f7da7a2..c82551a5f8 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/global/FetchProfileBinderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/global/FetchProfileBinderTest.java @@ -34,13 +34,13 @@ import org.hibernate.MappingException; import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchProfile; import org.hibernate.annotations.FetchProfiles; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.source.annotations.AnnotationBindingContextImpl; import org.hibernate.metamodel.source.annotations.JandexHelper; import org.hibernate.metamodel.source.internal.MetadataImpl; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.testing.junit4.BaseUnitTestCase; import static junit.framework.Assert.fail; @@ -58,7 +58,7 @@ public class FetchProfileBinderTest extends BaseUnitTestCase { @Before public void setUp() { - serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry(); + serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().buildServiceRegistry(); service = serviceRegistry.getService( ClassLoaderService.class ); meta = (MetadataImpl) new MetadataSources( serviceRegistry ).buildMetadata(); } diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/global/QueryBinderTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/global/QueryBinderTest.java index 50e8a80b04..f84ee9b688 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/global/QueryBinderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/global/QueryBinderTest.java @@ -30,6 +30,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.NotYetImplementedException; import org.hibernate.engine.query.spi.sql.NativeSQLQueryReturn; import org.hibernate.engine.query.spi.sql.NativeSQLQueryRootReturn; @@ -38,9 +39,8 @@ import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.source.annotations.AnnotationBindingContextImpl; import org.hibernate.metamodel.source.annotations.JandexHelper; import org.hibernate.metamodel.source.internal.MetadataImpl; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.testing.junit4.BaseUnitTestCase; import static junit.framework.Assert.assertEquals; @@ -58,7 +58,7 @@ public class QueryBinderTest extends BaseUnitTestCase { @Before public void setUp() { - serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry(); + serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().buildServiceRegistry(); service = serviceRegistry.getService( ClassLoaderService.class ); meta = (MetadataImpl) new MetadataSources( serviceRegistry ).buildMetadata(); } diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/util/BaseAnnotationIndexTestCase.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/util/BaseAnnotationIndexTestCase.java index 0166c85a0b..d067e55ecd 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/util/BaseAnnotationIndexTestCase.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/util/BaseAnnotationIndexTestCase.java @@ -38,8 +38,8 @@ import org.hibernate.metamodel.source.annotations.JandexHelper; import org.hibernate.metamodel.source.annotations.entity.EmbeddableHierarchy; import org.hibernate.metamodel.source.binder.EntityHierarchy; import org.hibernate.metamodel.source.internal.MetadataImpl; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.testing.junit4.BaseUnitTestCase; /** @@ -50,7 +50,7 @@ public abstract class BaseAnnotationIndexTestCase extends BaseUnitTestCase { @Before public void setUp() { - MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); meta = (MetadataImpl) sources.buildMetadata(); } diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/util/JandexHelperTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/util/JandexHelperTest.java index ec326a806a..a77347ccab 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/util/JandexHelperTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/util/JandexHelperTest.java @@ -43,12 +43,12 @@ import org.junit.Test; import org.hibernate.AssertionFailure; import org.hibernate.annotations.NamedNativeQuery; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.metamodel.source.annotations.HibernateDotNames; import org.hibernate.metamodel.source.annotations.JPADotNames; import org.hibernate.metamodel.source.annotations.JandexHelper; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.testing.junit4.BaseUnitTestCase; import static junit.framework.Assert.assertTrue; @@ -67,7 +67,7 @@ public class JandexHelperTest extends BaseUnitTestCase { @Before public void setUp() { - serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry(); + serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().buildServiceRegistry(); classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); } diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParserTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParserTests.java index ef2d70125d..c1935b1efd 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParserTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParserTests.java @@ -25,11 +25,12 @@ package org.hibernate.metamodel.source.annotations.xml; import org.junit.Test; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.binding.EntityBinding; import org.hibernate.metamodel.source.MappingException; import org.hibernate.metamodel.source.internal.MetadataImpl; -import org.hibernate.service.ServiceRegistryBuilder; + import org.hibernate.testing.junit4.BaseUnitTestCase; import static junit.framework.Assert.assertNotNull; @@ -40,7 +41,7 @@ import static junit.framework.Assert.assertNotNull; public class OrmXmlParserTests extends BaseUnitTestCase { @Test public void testSimpleOrmVersion2() { - MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); sources.addResource( "org/hibernate/metamodel/source/annotations/xml/orm-father.xml" ); MetadataImpl metadata = (MetadataImpl) sources.buildMetadata(); @@ -50,7 +51,7 @@ public class OrmXmlParserTests extends BaseUnitTestCase { @Test public void testSimpleOrmVersion1() { - MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); sources.addResource( "org/hibernate/metamodel/source/annotations/xml/orm-star.xml" ); MetadataImpl metadata = (MetadataImpl) sources.buildMetadata(); @@ -60,7 +61,7 @@ public class OrmXmlParserTests extends BaseUnitTestCase { @Test(expected = MappingException.class) public void testInvalidOrmXmlThrowsException() { - MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); sources.addResource( "org/hibernate/metamodel/source/annotations/xml/orm-invalid.xml" ); sources.buildMetadata(); } diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/mocker/AbstractMockerTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/mocker/AbstractMockerTest.java index 62a3c98b2e..0a47735ea3 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/mocker/AbstractMockerTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/mocker/AbstractMockerTest.java @@ -40,7 +40,7 @@ import org.hibernate.AnnotationException; import org.hibernate.HibernateException; import org.hibernate.internal.jaxb.mapping.orm.JaxbEntityMappings; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.testing.ServiceRegistryBuilder; import static org.junit.Assert.assertEquals; diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/mocker/XmlHelper.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/mocker/XmlHelper.java index e247c28084..e7cc270ade 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/mocker/XmlHelper.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/mocker/XmlHelper.java @@ -39,7 +39,7 @@ import org.xml.sax.SAXException; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.jaxb.JaxbRoot; import org.hibernate.internal.jaxb.Origin; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; /** * @author Hardy Ferentschik diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/internal/MetadataImplTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/internal/MetadataImplTest.java index 5720f43aa7..4fb1caa912 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/internal/MetadataImplTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/internal/MetadataImplTest.java @@ -29,11 +29,12 @@ import org.junit.Test; import org.hibernate.HibernateException; import org.hibernate.SessionFactory; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.metamodel.Metadata; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.SessionFactoryBuilder; import org.hibernate.metamodel.binding.FetchProfile; -import org.hibernate.service.ServiceRegistryBuilder; + import org.hibernate.testing.junit4.BaseUnitTestCase; import static junit.framework.Assert.assertEquals; @@ -48,28 +49,28 @@ public class MetadataImplTest extends BaseUnitTestCase { @Test(expected = IllegalArgumentException.class) public void testAddingNullClass() { - MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); sources.addClass( null ); sources.buildMetadata(); } @Test(expected = IllegalArgumentException.class) public void testAddingNullPackageName() { - MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); sources.addPackage( null ); sources.buildMetadata(); } @Test(expected = HibernateException.class) public void testAddingNonExistingPackageName() { - MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); sources.addPackage( "not.a.package" ); sources.buildMetadata(); } @Test public void testAddingPackageName() { - MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); sources.addPackage( "org.hibernate.metamodel.source.internal" ); MetadataImpl metadata = (MetadataImpl) sources.buildMetadata(); @@ -78,7 +79,7 @@ public class MetadataImplTest extends BaseUnitTestCase { @Test public void testAddingPackageNameWithTrailingDot() { - MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); sources.addPackage( "org.hibernate.metamodel.source.internal." ); MetadataImpl metadata = (MetadataImpl) sources.buildMetadata(); @@ -87,7 +88,7 @@ public class MetadataImplTest extends BaseUnitTestCase { @Test public void testGettingSessionFactoryBuilder() { - MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); Metadata metadata = sources.buildMetadata(); SessionFactoryBuilder sessionFactoryBuilder = metadata.getSessionFactoryBuilder(); diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/internal/SessionFactoryBuilderImplTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/internal/SessionFactoryBuilderImplTest.java index b32dfa9514..5f91b112c2 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/internal/SessionFactoryBuilderImplTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/internal/SessionFactoryBuilderImplTest.java @@ -35,10 +35,11 @@ import org.hibernate.Interceptor; import org.hibernate.ObjectNotFoundException; import org.hibernate.SessionFactory; import org.hibernate.Transaction; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.SessionFactoryBuilder; import org.hibernate.proxy.EntityNotFoundDelegate; -import org.hibernate.service.ServiceRegistryBuilder; + import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.type.Type; @@ -88,7 +89,7 @@ public class SessionFactoryBuilderImplTest extends BaseUnitTestCase { } private SessionFactoryBuilder getSessionFactoryBuilder() { - MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); + MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() ); sources.addAnnotatedClass( SimpleEntity.class ); MetadataImpl metadata = (MetadataImpl) sources.buildMetadata(); return metadata.getSessionFactoryBuilder(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java index 5a0688b67c..568559ea4e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java @@ -30,12 +30,12 @@ import java.util.List; import org.hibernate.Session; import org.hibernate.SessionFactory; +import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.exception.GenericJDBCException; -import org.hibernate.service.BootstrapServiceRegistryBuilder; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.internal.BootstrapServiceRegistryImpl; +import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl; import org.junit.Test; @@ -54,7 +54,7 @@ public class EmbeddableIntegratorTest extends BaseUnitTestCase { @Test(expected=GenericJDBCException.class) public void testWithoutIntegrator() { - ServiceRegistry reg = new ServiceRegistryBuilder(new BootstrapServiceRegistryImpl()) + ServiceRegistry reg = new StandardServiceRegistryBuilder(new BootstrapServiceRegistryImpl()) .buildServiceRegistry(); SessionFactory sf = new Configuration() @@ -78,7 +78,7 @@ public class EmbeddableIntegratorTest extends BaseUnitTestCase { @Test public void testWithIntegrator() { - ServiceRegistry reg = new ServiceRegistryBuilder( + ServiceRegistry reg = new StandardServiceRegistryBuilder( new BootstrapServiceRegistryBuilder().with( new InvestorIntegrator() ).build() ).buildServiceRegistry(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/cfg/persister/PersisterClassProviderTest.java b/hibernate-core/src/test/java/org/hibernate/test/cfg/persister/PersisterClassProviderTest.java index 177df15ed2..706391588b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/cfg/persister/PersisterClassProviderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/cfg/persister/PersisterClassProviderTest.java @@ -24,10 +24,11 @@ import org.junit.Test; import org.hibernate.MappingException; import org.hibernate.SessionFactory; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.persister.spi.PersisterClassResolver; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.ServiceRegistryBuilder; + import org.hibernate.testing.junit4.BaseUnitTestCase; import static org.junit.Assert.assertEquals; @@ -42,15 +43,15 @@ public class PersisterClassProviderTest extends BaseUnitTestCase { Configuration cfg = new Configuration(); cfg.addAnnotatedClass( Gate.class ); - ServiceRegistry serviceRegistry = new ServiceRegistryBuilder() + ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder() .applySettings( cfg.getProperties() ) .buildServiceRegistry(); //no exception as the GoofyPersisterClassProvider is not set SessionFactory sessionFactory = cfg.buildSessionFactory( serviceRegistry ); sessionFactory.close(); - ServiceRegistryBuilder.destroy( serviceRegistry ); + StandardServiceRegistryBuilder.destroy( serviceRegistry ); - serviceRegistry = new ServiceRegistryBuilder() + serviceRegistry = new StandardServiceRegistryBuilder() .applySettings( cfg.getProperties() ) .addService( PersisterClassResolver.class, new GoofyPersisterClassProvider() ) .buildServiceRegistry(); @@ -69,13 +70,13 @@ public class PersisterClassProviderTest extends BaseUnitTestCase { ); } finally { - ServiceRegistryBuilder.destroy( serviceRegistry ); + StandardServiceRegistryBuilder.destroy( serviceRegistry ); } cfg = new Configuration(); cfg.addAnnotatedClass( Portal.class ); cfg.addAnnotatedClass( Window.class ); - serviceRegistry = new ServiceRegistryBuilder() + serviceRegistry = new StandardServiceRegistryBuilder() .applySettings( cfg.getProperties() ) .addService( PersisterClassResolver.class, new GoofyPersisterClassProvider() ) .buildServiceRegistry(); @@ -91,14 +92,14 @@ public class PersisterClassProviderTest extends BaseUnitTestCase { ( (GoofyException) e.getCause() ).getValue() ); } finally { - ServiceRegistryBuilder.destroy( serviceRegistry ); + StandardServiceRegistryBuilder.destroy( serviceRegistry ); } cfg = new Configuration(); cfg.addAnnotatedClass( Tree.class ); cfg.addAnnotatedClass( Palmtree.class ); - serviceRegistry = new ServiceRegistryBuilder() + serviceRegistry = new StandardServiceRegistryBuilder() .applySettings( cfg.getProperties() ) .addService( PersisterClassResolver.class, new GoofyPersisterClassProvider() ) .buildServiceRegistry(); @@ -114,7 +115,7 @@ public class PersisterClassProviderTest extends BaseUnitTestCase { ( (GoofyException) e.getCause() ).getValue() ); } finally { - ServiceRegistryBuilder.destroy( serviceRegistry ); + StandardServiceRegistryBuilder.destroy( serviceRegistry ); } } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/common/BasicTestingJdbcServiceImpl.java b/hibernate-core/src/test/java/org/hibernate/test/common/BasicTestingJdbcServiceImpl.java index a84e7dcf29..c8e73cba51 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/common/BasicTestingJdbcServiceImpl.java +++ b/hibernate-core/src/test/java/org/hibernate/test/common/BasicTestingJdbcServiceImpl.java @@ -37,7 +37,7 @@ import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.jdbc.spi.ResultSetWrapper; import org.hibernate.engine.jdbc.spi.SqlExceptionHelper; import org.hibernate.engine.jdbc.spi.SqlStatementLogger; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.spi.Stoppable; import org.hibernate.testing.env.ConnectionProviderBuilder; diff --git a/hibernate-core/src/test/java/org/hibernate/test/common/JdbcConnectionAccessImpl.java b/hibernate-core/src/test/java/org/hibernate/test/common/JdbcConnectionAccessImpl.java index 8ba9d7555a..2ba0228189 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/common/JdbcConnectionAccessImpl.java +++ b/hibernate-core/src/test/java/org/hibernate/test/common/JdbcConnectionAccessImpl.java @@ -29,7 +29,7 @@ import java.sql.SQLException; import org.hibernate.engine.jdbc.spi.JdbcConnectionAccess; import org.hibernate.engine.transaction.spi.TransactionEnvironment; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; /** * @author Steve Ebersole diff --git a/hibernate-core/src/test/java/org/hibernate/test/common/TransactionEnvironmentImpl.java b/hibernate-core/src/test/java/org/hibernate/test/common/TransactionEnvironmentImpl.java index 41e8f596a4..be0ed8f3a5 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/common/TransactionEnvironmentImpl.java +++ b/hibernate-core/src/test/java/org/hibernate/test/common/TransactionEnvironmentImpl.java @@ -30,7 +30,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.transaction.spi.TransactionEnvironment; import org.hibernate.engine.transaction.spi.TransactionFactory; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.stat.internal.ConcurrentStatisticsImpl; import org.hibernate.stat.spi.StatisticsImplementor; diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java index 6de8f89e25..2db4ec9c42 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java @@ -16,7 +16,7 @@ import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; import org.hibernate.internal.util.SerializationHelper; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.testing.jta.TestingJtaBootstrap; import org.hibernate.testing.jta.TestingJtaPlatformImpl; diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java index 103665315a..32525c5289 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java @@ -31,8 +31,8 @@ import org.hibernate.ConnectionReleaseMode; import org.hibernate.Session; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; -import org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.spi.Stoppable; import org.hibernate.testing.AfterClassOnce; import org.hibernate.testing.BeforeClassOnce; diff --git a/hibernate-core/src/test/java/org/hibernate/test/events/CallbackTest.java b/hibernate-core/src/test/java/org/hibernate/test/events/CallbackTest.java index 8b1aafb885..acf281804b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/events/CallbackTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/events/CallbackTest.java @@ -30,6 +30,7 @@ import org.junit.Test; import org.hibernate.HibernateException; import org.hibernate.SessionFactory; import org.hibernate.SessionFactoryObserver; +import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.event.service.spi.EventListenerRegistry; @@ -38,7 +39,6 @@ import org.hibernate.event.spi.DeleteEventListener; import org.hibernate.event.spi.EventType; import org.hibernate.integrator.spi.Integrator; import org.hibernate.metamodel.source.MetadataImplementor; -import org.hibernate.service.BootstrapServiceRegistryBuilder; import org.hibernate.service.spi.SessionFactoryServiceRegistry; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; diff --git a/hibernate-core/src/test/java/org/hibernate/test/extendshbm/ExtendsTest.java b/hibernate-core/src/test/java/org/hibernate/test/extendshbm/ExtendsTest.java index bb7a228b18..d4ce19796c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/extendshbm/ExtendsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/extendshbm/ExtendsTest.java @@ -7,7 +7,7 @@ import org.junit.Test; import org.hibernate.HibernateException; import org.hibernate.cfg.Configuration; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.testing.ServiceRegistryBuilder; import org.hibernate.testing.junit4.BaseUnitTestCase; diff --git a/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java b/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java index 516b659e86..5f37af583f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java @@ -23,9 +23,10 @@ */ package org.hibernate.test.fileimport; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; -import org.hibernate.service.ServiceRegistryBuilder; + import org.hibernate.testing.TestForIssue; import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor; import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor; @@ -41,7 +42,7 @@ public class CommandExtractorServiceTest extends MultiLineImportFileTest { } @Override - protected void prepareBasicRegistryBuilder(ServiceRegistryBuilder serviceRegistryBuilder) { + protected void prepareBasicRegistryBuilder(StandardServiceRegistryBuilder serviceRegistryBuilder) { super.prepareBasicRegistryBuilder( serviceRegistryBuilder ); serviceRegistryBuilder.addService( ImportSqlCommandExtractor.class, new MultipleLinesSqlCommandExtractor() ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/flush/TestAutoFlushBeforeQueryExecution.java b/hibernate-core/src/test/java/org/hibernate/test/flush/TestAutoFlushBeforeQueryExecution.java index 1b356fbc98..b86bf36cfa 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/flush/TestAutoFlushBeforeQueryExecution.java +++ b/hibernate-core/src/test/java/org/hibernate/test/flush/TestAutoFlushBeforeQueryExecution.java @@ -33,7 +33,6 @@ import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; -import org.hibernate.collection.internal.PersistentSet; import org.hibernate.engine.spi.ActionQueue; import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.SessionFactoryImplementor; @@ -45,7 +44,7 @@ import org.hibernate.event.spi.PreUpdateEventListener; import org.hibernate.integrator.spi.Integrator; import org.hibernate.internal.SessionImpl; import org.hibernate.metamodel.source.MetadataImplementor; -import org.hibernate.service.BootstrapServiceRegistryBuilder; +import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.service.spi.SessionFactoryServiceRegistry; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; diff --git a/hibernate-core/src/test/java/org/hibernate/test/flush/TestCollectionInitializingDuringFlush.java b/hibernate-core/src/test/java/org/hibernate/test/flush/TestCollectionInitializingDuringFlush.java index dcfb74c33b..8170107e61 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/flush/TestCollectionInitializingDuringFlush.java +++ b/hibernate-core/src/test/java/org/hibernate/test/flush/TestCollectionInitializingDuringFlush.java @@ -27,6 +27,7 @@ import org.junit.Test; import org.hibernate.Hibernate; import org.hibernate.Session; +import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.event.service.spi.EventListenerRegistry; @@ -35,7 +36,6 @@ import org.hibernate.event.spi.PreUpdateEvent; import org.hibernate.event.spi.PreUpdateEventListener; import org.hibernate.integrator.spi.Integrator; import org.hibernate.metamodel.source.MetadataImplementor; -import org.hibernate.service.BootstrapServiceRegistryBuilder; import org.hibernate.service.spi.SessionFactoryServiceRegistry; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; diff --git a/hibernate-core/src/test/java/org/hibernate/test/jdbc/proxies/BatchingTest.java b/hibernate-core/src/test/java/org/hibernate/test/jdbc/proxies/BatchingTest.java index 5f787044b8..df5624df10 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/jdbc/proxies/BatchingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/jdbc/proxies/BatchingTest.java @@ -31,6 +31,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey; import org.hibernate.engine.jdbc.batch.internal.BatchBuilderImpl; import org.hibernate.engine.jdbc.batch.internal.BatchingBatch; @@ -45,8 +46,7 @@ import org.hibernate.engine.transaction.spi.TransactionContext; import org.hibernate.engine.transaction.spi.TransactionImplementor; import org.hibernate.jdbc.Expectation; import org.hibernate.jdbc.Expectations; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.test.common.JournalingBatchObserver; import org.hibernate.test.common.JournalingTransactionObserver; import org.hibernate.test.common.TransactionContextImpl; @@ -67,7 +67,7 @@ public class BatchingTest extends BaseUnitTestCase implements BatchKey { @Before public void setUp() throws Exception { - serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder() + serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings( ConnectionProviderBuilder.getConnectionProviderProperties() ) .buildServiceRegistry(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java b/hibernate-core/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java index 40f8cb9eff..06ec5a95ea 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java @@ -27,6 +27,7 @@ import java.io.Serializable; import java.util.IdentityHashMap; import javax.persistence.EntityNotFoundException; +import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.engine.spi.CascadingAction; @@ -45,7 +46,6 @@ import org.hibernate.event.spi.PersistEventListener; import org.hibernate.integrator.spi.Integrator; import org.hibernate.metamodel.source.MetadataImplementor; import org.hibernate.proxy.EntityNotFoundDelegate; -import org.hibernate.service.BootstrapServiceRegistryBuilder; import org.hibernate.service.spi.SessionFactoryServiceRegistry; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; diff --git a/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java index 412170b778..6b22592a89 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java @@ -37,7 +37,7 @@ import org.hibernate.event.spi.LoadEvent; import org.hibernate.event.spi.LoadEventListener; import org.hibernate.integrator.spi.Integrator; import org.hibernate.metamodel.source.MetadataImplementor; -import org.hibernate.service.BootstrapServiceRegistryBuilder; +import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.service.spi.SessionFactoryServiceRegistry; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java b/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java index 121cb08d82..9d6cb6c83c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java @@ -84,7 +84,7 @@ import org.hibernate.internal.util.collections.JoinedIterator; import org.hibernate.jdbc.AbstractReturningWork; import org.hibernate.jdbc.AbstractWork; import org.hibernate.proxy.HibernateProxy; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.testing.DialectChecks; import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialectFeature; diff --git a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/ConfigurationValidationTest.java b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/ConfigurationValidationTest.java index f258c62f57..b84e8e4435 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/ConfigurationValidationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/ConfigurationValidationTest.java @@ -4,10 +4,10 @@ import org.junit.Test; import org.hibernate.ConnectionReleaseMode; import org.hibernate.MultiTenancyStrategy; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider; import org.hibernate.service.spi.ServiceException; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.testing.TestForIssue; @@ -25,7 +25,7 @@ public class ConfigurationValidationTest extends BaseUnitTestCase { cfg.getProperties().put( Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA ); cfg.setProperty( Environment.MULTI_TENANT_CONNECTION_PROVIDER, "class.not.present.in.classpath" ); cfg.buildMappings(); - ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) new ServiceRegistryBuilder() + ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) new StandardServiceRegistryBuilder() .applySettings( cfg.getProperties() ).buildServiceRegistry(); cfg.buildSessionFactory( serviceRegistry ); } @@ -37,7 +37,7 @@ public class ConfigurationValidationTest extends BaseUnitTestCase { cfg.getProperties().put( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.AFTER_STATEMENT.name() ); cfg.buildMappings(); - ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) new ServiceRegistryBuilder() + ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) new StandardServiceRegistryBuilder() .applySettings( cfg.getProperties() ) .addService( MultiTenantConnectionProvider.class, diff --git a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/TestingConnectionProvider.java b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/TestingConnectionProvider.java index 64d78abae8..8ca54675f3 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/TestingConnectionProvider.java +++ b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/TestingConnectionProvider.java @@ -26,8 +26,8 @@ package org.hibernate.test.multitenancy; import java.util.HashMap; import java.util.Map; -import org.hibernate.service.jdbc.connections.spi.AbstractMultiTenantConnectionProvider; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.AbstractMultiTenantConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; /** * @author Steve Ebersole diff --git a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java index d20f253416..5ddcfc1837 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java @@ -38,11 +38,11 @@ import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.mapping.RootClass; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl; -import org.hibernate.service.jdbc.connections.spi.AbstractMultiTenantConnectionProvider; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; +import org.hibernate.engine.jdbc.connections.spi.AbstractMultiTenantConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.testing.cache.CachingRegionFactory; import org.hibernate.testing.env.ConnectionProviderBuilder; @@ -66,7 +66,7 @@ public class SchemaBasedMultiTenancyTest extends BaseUnitTestCase { AbstractMultiTenantConnectionProvider multiTenantConnectionProvider = buildMultiTenantConnectionProvider(); Configuration cfg = buildConfiguration(); - serviceRegistry = (ServiceRegistryImplementor) new ServiceRegistryBuilder() + serviceRegistry = (ServiceRegistryImplementor) new StandardServiceRegistryBuilder() .applySettings( cfg.getProperties() ) .addService( MultiTenantConnectionProvider.class, multiTenantConnectionProvider ) .buildServiceRegistry(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/service/ClassLoaderServiceImplTest.java b/hibernate-core/src/test/java/org/hibernate/test/service/ClassLoaderServiceImplTest.java index 1ada3caec3..7609a5ffc8 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/service/ClassLoaderServiceImplTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/service/ClassLoaderServiceImplTest.java @@ -1,6 +1,6 @@ package org.hibernate.test.service; -import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl; +import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl; import org.junit.Assert; import org.junit.Test; diff --git a/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java b/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java index 12b5a287b7..ef7f279192 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java @@ -27,14 +27,14 @@ import java.util.Properties; import org.junit.Test; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Environment; import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.jdbc.spi.JdbcServices; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.internal.StandardServiceRegistryImpl; -import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl; -import org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; +import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; +import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.testing.env.ConnectionProviderBuilder; import org.hibernate.testing.junit4.BaseUnitTestCase; @@ -47,7 +47,7 @@ import static org.junit.Assert.assertTrue; public class ServiceBootstrappingTest extends BaseUnitTestCase { @Test public void testBasicBuild() { - StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder() + StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings( ConnectionProviderBuilder.getConnectionProviderProperties() ) .buildServiceRegistry(); JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); @@ -64,7 +64,7 @@ public class ServiceBootstrappingTest extends BaseUnitTestCase { Properties props = ConnectionProviderBuilder.getConnectionProviderProperties(); props.put( Environment.SHOW_SQL, "true" ); - StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder() + StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings( props ) .buildServiceRegistry(); @@ -79,7 +79,7 @@ public class ServiceBootstrappingTest extends BaseUnitTestCase { @Test public void testBuildWithServiceOverride() { - StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder() + StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings( ConnectionProviderBuilder.getConnectionProviderProperties() ) .buildServiceRegistry(); JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); @@ -90,7 +90,7 @@ public class ServiceBootstrappingTest extends BaseUnitTestCase { Properties props = ConnectionProviderBuilder.getConnectionProviderProperties(); props.setProperty( Environment.DIALECT, H2Dialect.class.getName() ); - serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder() + serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings( props ) .addService( ConnectionProvider.class, new UserSuppliedConnectionProviderImpl() ) .buildServiceRegistry(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/transaction/jdbc/TestExpectedUsage.java b/hibernate-core/src/test/java/org/hibernate/test/transaction/jdbc/TestExpectedUsage.java index fcd64f33b0..accc188c0a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/transaction/jdbc/TestExpectedUsage.java +++ b/hibernate-core/src/test/java/org/hibernate/test/transaction/jdbc/TestExpectedUsage.java @@ -33,12 +33,12 @@ import org.junit.Before; import org.junit.Test; import org.hibernate.ConnectionReleaseMode; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor; import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl; import org.hibernate.engine.transaction.spi.TransactionContext; import org.hibernate.engine.transaction.spi.TransactionImplementor; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.test.common.JournalingTransactionObserver; import org.hibernate.test.common.TransactionContextImpl; import org.hibernate.test.common.TransactionEnvironmentImpl; @@ -58,7 +58,7 @@ public class TestExpectedUsage extends BaseUnitTestCase { @Before public void setUp() throws Exception { - serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder() + serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings( ConnectionProviderBuilder.getConnectionProviderProperties() ) .buildServiceRegistry(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/BasicDrivingTest.java b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/BasicDrivingTest.java index 397ef9546c..4230cba476 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/BasicDrivingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/BasicDrivingTest.java @@ -34,15 +34,15 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Environment; import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor; import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl; import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory; import org.hibernate.engine.transaction.spi.TransactionContext; import org.hibernate.engine.transaction.spi.TransactionImplementor; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.internal.StandardServiceRegistryImpl; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.test.common.JournalingTransactionObserver; import org.hibernate.test.common.TransactionContextImpl; import org.hibernate.test.common.TransactionEnvironmentImpl; @@ -70,7 +70,7 @@ public class BasicDrivingTest extends BaseUnitTestCase { configValues.putAll( ConnectionProviderBuilder.getConnectionProviderProperties() ); configValues.put( Environment.TRANSACTION_STRATEGY, JtaTransactionFactory.class.getName() ); TestingJtaBootstrap.prepare( configValues ); - serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder() + serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings( configValues ) .buildServiceRegistry(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java index c983b85fd2..0524656987 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java @@ -36,15 +36,15 @@ import org.junit.Before; import org.junit.Test; import org.hibernate.ConnectionReleaseMode; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Environment; import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor; import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl; import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; import org.hibernate.engine.transaction.spi.TransactionContext; import org.hibernate.engine.transaction.spi.TransactionImplementor; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.internal.StandardServiceRegistryImpl; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.test.common.JournalingTransactionObserver; import org.hibernate.test.common.TransactionContextImpl; import org.hibernate.test.common.TransactionEnvironmentImpl; @@ -71,7 +71,7 @@ public class ManagedDrivingTest extends BaseUnitTestCase { TestingJtaBootstrap.prepare( configValues ); configValues.put( Environment.TRANSACTION_STRATEGY, CMTTransactionFactory.class.getName() ); - serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder() + serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings( configValues ) .buildServiceRegistry(); } diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AbstractEhcacheRegionFactory.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AbstractEhcacheRegionFactory.java index c0e3256ed8..9b9a28c2ec 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AbstractEhcacheRegionFactory.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AbstractEhcacheRegionFactory.java @@ -51,7 +51,7 @@ import org.hibernate.cache.spi.RegionFactory; import org.hibernate.cache.spi.TimestampsRegion; import org.hibernate.cache.spi.access.AccessType; import org.hibernate.cfg.Settings; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.service.spi.InjectService; /** diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java index 7518266934..8c10ee5c81 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java @@ -66,6 +66,8 @@ import org.hibernate.MappingException; import org.hibernate.MappingNotFoundException; import org.hibernate.SessionFactory; import org.hibernate.SessionFactoryObserver; +import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.cfg.NamingStrategy; @@ -95,13 +97,11 @@ import org.hibernate.metamodel.source.annotations.JPADotNames; import org.hibernate.metamodel.source.annotations.JandexHelper; import org.hibernate.proxy.EntityNotFoundDelegate; import org.hibernate.secure.internal.JACCConfiguration; -import org.hibernate.service.BootstrapServiceRegistry; -import org.hibernate.service.BootstrapServiceRegistryBuilder; +import org.hibernate.boot.registry.BootstrapServiceRegistry; import org.hibernate.service.ConfigLoader; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.service.spi.ServiceRegistryImplementor; /** @@ -132,7 +132,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil private final PersistenceUnitDescriptor persistenceUnit; private final SettingsImpl settings = new SettingsImpl(); - private final ServiceRegistryBuilder serviceRegistryBuilder; + private final StandardServiceRegistryBuilder serviceRegistryBuilder; private final Map configurationValues; private final List jaccDefinitions = new ArrayList(); @@ -167,7 +167,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil // First we build the boot-strap service registry, which mainly handles class loader interactions final BootstrapServiceRegistry bootstrapServiceRegistry = buildBootstrapServiceRegistry( integrationSettings ); // And the main service registry. This is needed to start adding configuration values, etc - this.serviceRegistryBuilder = new ServiceRegistryBuilder( bootstrapServiceRegistry ); + this.serviceRegistryBuilder = new StandardServiceRegistryBuilder( bootstrapServiceRegistry ); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Next we build a merged map of all the configuration values @@ -317,7 +317,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil } /** - * Builds the {@link BootstrapServiceRegistry} used to eventually build the {@link ServiceRegistryBuilder}; mainly + * Builds the {@link BootstrapServiceRegistry} used to eventually build the {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder}; mainly * used here during instantiation to define class-loading behavior. * * @param integrationSettings Any integration settings passed by the EE container or SE application 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 60aff1bc0b..360a71ead4 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 @@ -59,8 +59,8 @@ import org.hibernate.jpa.packaging.internal.JarVisitorFactory; import org.hibernate.jpa.internal.util.ConfigurationHelper; import org.hibernate.internal.util.StringHelper; import org.hibernate.metamodel.source.XsdException; -import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; /** * Used by Hibernate to parse {@code persistence.xml} files in SE environments. diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/CallbackProcessorImpl.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/CallbackProcessorImpl.java index cdbdb2569d..37c8c0a814 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/CallbackProcessorImpl.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/CallbackProcessorImpl.java @@ -31,13 +31,12 @@ import org.jboss.logging.Logger; import org.hibernate.MappingException; import org.hibernate.jpa.event.spi.jpa.Callback; -import org.hibernate.jpa.event.spi.jpa.CallbackRegistry; import org.hibernate.jpa.event.spi.jpa.ListenerFactory; import org.hibernate.metamodel.binding.EntityBinding; import org.hibernate.metamodel.source.MetadataImplementor; import org.hibernate.metamodel.source.binder.JpaCallbackClass; -import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.classloading.spi.ClassLoadingException; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.service.spi.SessionFactoryServiceRegistry; /** diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/spi/JpaIntegrator.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/spi/JpaIntegrator.java index 0c05b5b9fb..41649e42d6 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/spi/JpaIntegrator.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/spi/JpaIntegrator.java @@ -55,7 +55,6 @@ import org.hibernate.jpa.event.internal.core.JpaPostLoadEventListener; import org.hibernate.jpa.event.internal.core.JpaPostUpdateEventListener; import org.hibernate.jpa.event.internal.core.JpaSaveEventListener; import org.hibernate.jpa.event.internal.core.JpaSaveOrUpdateEventListener; -import org.hibernate.jpa.event.internal.jpa.BeanManagerListenerFactory; import org.hibernate.jpa.event.internal.jpa.CallbackProcessor; import org.hibernate.jpa.event.internal.jpa.CallbackProcessorImpl; import org.hibernate.jpa.event.internal.jpa.CallbackRegistryConsumer; @@ -71,7 +70,7 @@ import org.hibernate.secure.internal.JACCPreInsertEventListener; import org.hibernate.secure.internal.JACCPreLoadEventListener; import org.hibernate.secure.internal.JACCPreUpdateEventListener; import org.hibernate.secure.internal.JACCSecurityListener; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.SessionFactoryServiceRegistry; diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/spi/AbstractEntityManagerImpl.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/spi/AbstractEntityManagerImpl.java index a81080cb9b..74d2444f5e 100755 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/spi/AbstractEntityManagerImpl.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/spi/AbstractEntityManagerImpl.java @@ -125,7 +125,7 @@ import org.hibernate.jpa.internal.util.CacheModeHelper; import org.hibernate.jpa.internal.util.ConfigurationHelper; import org.hibernate.jpa.internal.util.LockModeTypeHelper; import org.hibernate.proxy.HibernateProxy; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.transform.BasicTransformerAdapter; import org.hibernate.type.Type; diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/BaseEntityManagerFunctionalTestCase.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/BaseEntityManagerFunctionalTestCase.java index 27df78bada..4fca26b4e3 100644 --- a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/BaseEntityManagerFunctionalTestCase.java +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/BaseEntityManagerFunctionalTestCase.java @@ -46,7 +46,7 @@ import org.hibernate.internal.util.StringHelper; import org.hibernate.jpa.HibernatePersistenceProvider; import org.hibernate.jpa.boot.spi.Bootstrap; import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.junit.After; import org.junit.Before; diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java index 9ccd515913..1316da28d3 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java @@ -40,7 +40,7 @@ import org.hibernate.envers.strategy.ValidityAuditStrategy; import org.hibernate.envers.synchronization.AuditProcessManager; import org.hibernate.envers.tools.reflection.ReflectionTools; import org.hibernate.property.Getter; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; /** * @author Adam Warski (adam at warski dot org) diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversIntegrator.java b/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversIntegrator.java index a04d21fa1a..65f84b1df0 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversIntegrator.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversIntegrator.java @@ -34,7 +34,7 @@ import org.hibernate.integrator.spi.Integrator; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.metamodel.source.MetadataImplementor; -import org.hibernate.service.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.service.spi.SessionFactoryServiceRegistry; /** diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/BaseEnversJPAFunctionalTestCase.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/BaseEnversJPAFunctionalTestCase.java index 3eea5518fa..8e76f72c47 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/BaseEnversJPAFunctionalTestCase.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/BaseEnversJPAFunctionalTestCase.java @@ -47,7 +47,7 @@ import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl; import org.hibernate.jpa.boot.spi.Bootstrap; import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor; import org.hibernate.jpa.internal.EntityManagerFactoryImpl; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.junit.After; diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/performance/AbstractEntityManagerTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/performance/AbstractEntityManagerTest.java index a4c6e56b39..da3fdd326a 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/performance/AbstractEntityManagerTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/performance/AbstractEntityManagerTest.java @@ -28,6 +28,7 @@ import java.util.Arrays; import java.util.Properties; import javax.persistence.EntityManager; +import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.jpa.test.PersistenceUnitDescriptorAdapter; import org.hibernate.envers.test.AbstractEnversTest; import org.junit.Before; @@ -41,8 +42,7 @@ import org.hibernate.jpa.internal.EntityManagerFactoryImpl; import org.hibernate.envers.AuditReader; import org.hibernate.envers.AuditReaderFactory; import org.hibernate.envers.event.EnversIntegrator; -import org.hibernate.service.BootstrapServiceRegistryBuilder; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.testing.AfterClassOnce; import org.hibernate.testing.BeforeClassOnce; diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/HibernateTransactionManagerLookup.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/HibernateTransactionManagerLookup.java index e852e20e88..7ece4bcec0 100644 --- a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/HibernateTransactionManagerLookup.java +++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/HibernateTransactionManagerLookup.java @@ -25,7 +25,7 @@ import java.util.Properties; import javax.transaction.TransactionManager; import org.hibernate.cfg.Settings; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; /** * HibernateTransactionManagerLookup. diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractEntityCollectionRegionTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractEntityCollectionRegionTestCase.java index 6ee5e505d4..16e007b671 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractEntityCollectionRegionTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractEntityCollectionRegionTestCase.java @@ -88,7 +88,7 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg // // Make it non-transactional // cfg.getProperties().remove( AvailableSettings.JTA_PLATFORM ); // regionFactory = CacheTestUtil.startRegionFactory( -// ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ), +// StandardServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ), // cfg, // getCacheTestSupport() // ); diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java index babe5f8e48..88d2530530 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java @@ -29,13 +29,14 @@ import org.infinispan.transaction.tm.BatchModeTransactionManager; import org.jboss.logging.Logger; import org.junit.Test; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cache.infinispan.InfinispanRegionFactory; import org.hibernate.cache.infinispan.util.CacheAdapter; import org.hibernate.cache.spi.GeneralDataRegion; import org.hibernate.cache.spi.QueryResultsRegion; import org.hibernate.cache.spi.Region; import org.hibernate.cfg.Configuration; -import org.hibernate.service.ServiceRegistryBuilder; + import org.hibernate.test.cache.infinispan.util.CacheTestUtil; import static org.junit.Assert.assertEquals; @@ -77,7 +78,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm private void evictOrRemoveTest() throws Exception { Configuration cfg = createConfiguration(); InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( - new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), + new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); @@ -93,7 +94,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm cfg = createConfiguration(); regionFactory = CacheTestUtil.startRegionFactory( - new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), + new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); @@ -147,7 +148,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm private void evictOrRemoveAllTest(String configName) throws Exception { Configuration cfg = createConfiguration(); InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( - new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), + new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); @@ -165,7 +166,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm cfg = createConfiguration(); regionFactory = CacheTestUtil.startRegionFactory( - new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), + new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java index f2601409ef..02edfd8bee 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java @@ -40,8 +40,8 @@ import org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl; import org.hibernate.cache.infinispan.tm.HibernateTransactionManagerLookup; import org.hibernate.cache.infinispan.util.CacheAdapter; import org.hibernate.cfg.Settings; -import org.hibernate.service.jta.platform.internal.AbstractJtaPlatform; -import org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform; import org.hibernate.testing.ServiceRegistryBuilder; import static org.junit.Assert.assertEquals; diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/NodeEnvironment.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/NodeEnvironment.java index abeea66625..dd4d31de8c 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/NodeEnvironment.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/NodeEnvironment.java @@ -27,14 +27,14 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.Callable; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cache.infinispan.InfinispanRegionFactory; import org.hibernate.cache.infinispan.collection.CollectionRegionImpl; import org.hibernate.cache.infinispan.entity.EntityRegionImpl; import org.hibernate.cache.infinispan.util.FlagAdapter; import org.hibernate.cache.spi.CacheDataDescription; import org.hibernate.cfg.Configuration; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.test.cache.infinispan.util.CacheTestUtil; import static org.hibernate.cache.infinispan.util.CacheHelper.withinTx; @@ -111,7 +111,7 @@ public class NodeEnvironment { } public void prepare() throws Exception { - serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder() + serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings( configuration.getProperties() ) .buildServiceRegistry(); regionFactory = CacheTestUtil.startRegionFactory( serviceRegistry, configuration ); diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/ConcurrentWriteTest.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/ConcurrentWriteTest.java index 2c92b77d6d..7ef3ca0ebc 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/ConcurrentWriteTest.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/ConcurrentWriteTest.java @@ -47,8 +47,8 @@ import org.hibernate.Session; import org.hibernate.cache.infinispan.InfinispanRegionFactory; import org.hibernate.cache.spi.RegionFactory; import org.hibernate.cfg.Configuration; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.stat.SecondLevelCacheStatistics; import org.hibernate.test.cache.infinispan.functional.cluster.DualNodeConnectionProviderImpl; import org.hibernate.test.cache.infinispan.functional.cluster.DualNodeJtaPlatformImpl; diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/SingleNodeTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/SingleNodeTestCase.java index a270cd252f..d383500b38 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/SingleNodeTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/SingleNodeTestCase.java @@ -37,8 +37,8 @@ import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; import org.hibernate.engine.transaction.spi.TransactionFactory; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.test.cache.infinispan.tm.JtaPlatformImpl; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java index 2a92e251a2..ffc9da4ac4 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java @@ -38,8 +38,8 @@ import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; import org.hibernate.engine.transaction.spi.TransactionFactory; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.stat.SecondLevelCacheStatistics; import org.hibernate.test.cache.infinispan.functional.Contact; import org.hibernate.test.cache.infinispan.functional.Customer; diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeConnectionProviderImpl.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeConnectionProviderImpl.java index 53afc9aa93..78318ae252 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeConnectionProviderImpl.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeConnectionProviderImpl.java @@ -29,7 +29,7 @@ import java.util.Map; import org.hibernate.HibernateException; import org.hibernate.service.UnknownUnwrapTypeException; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.spi.Configurable; import org.hibernate.service.spi.Stoppable; import org.hibernate.testing.env.ConnectionProviderBuilder; diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeJtaPlatformImpl.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeJtaPlatformImpl.java index 80fe23837e..ac8f980aad 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeJtaPlatformImpl.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeJtaPlatformImpl.java @@ -33,7 +33,7 @@ import javax.transaction.UserTransaction; import org.hibernate.HibernateException; import org.hibernate.TransactionException; import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.service.spi.Configurable; /** diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTestCase.java index 4735d0693a..d75ef850d6 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTestCase.java @@ -33,7 +33,7 @@ import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; /** diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java index 7d52f2df21..3991bd708c 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java @@ -36,6 +36,7 @@ import org.infinispan.transaction.tm.BatchModeTransactionManager; import org.infinispan.util.concurrent.IsolationLevel; import org.jboss.logging.Logger; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cache.infinispan.InfinispanRegionFactory; import org.hibernate.cache.infinispan.util.CacheAdapter; import org.hibernate.cache.infinispan.util.CacheAdapterImpl; @@ -46,7 +47,7 @@ import org.hibernate.cache.spi.GeneralDataRegion; import org.hibernate.cache.spi.QueryResultsRegion; import org.hibernate.cache.spi.Region; import org.hibernate.cfg.Configuration; -import org.hibernate.service.ServiceRegistryBuilder; + import org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTestCase; import org.hibernate.test.cache.infinispan.util.CacheTestUtil; @@ -112,7 +113,7 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase { private void putDoesNotBlockGetTest() throws Exception { Configuration cfg = createConfiguration(); InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( - new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), + new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); @@ -212,7 +213,7 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase { private void getDoesNotBlockPutTest() throws Exception { Configuration cfg = createConfiguration(); InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( - new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), + new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/timestamp/TimestampsRegionImplTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/timestamp/TimestampsRegionImplTestCase.java index b0dffd9576..29e2ba7329 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/timestamp/TimestampsRegionImplTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/timestamp/TimestampsRegionImplTestCase.java @@ -38,6 +38,7 @@ import org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved; import org.infinispan.notifications.cachelistener.annotation.CacheEntryVisited; import org.infinispan.notifications.cachelistener.event.Event; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cache.infinispan.InfinispanRegionFactory; import org.hibernate.cache.infinispan.impl.ClassLoaderAwareCache; import org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl; @@ -48,7 +49,7 @@ import org.hibernate.cache.spi.CacheDataDescription; import org.hibernate.cache.spi.Region; import org.hibernate.cache.spi.UpdateTimestampsCache; import org.hibernate.cfg.Configuration; -import org.hibernate.service.ServiceRegistryBuilder; + import org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTestCase; import org.hibernate.test.cache.infinispan.functional.classloader.Account; import org.hibernate.test.cache.infinispan.functional.classloader.AccountHolder; @@ -81,7 +82,7 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC public void testClearTimestampsRegionInIsolated() throws Exception { Configuration cfg = createConfiguration(); InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( - new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), + new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); @@ -90,7 +91,7 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC Configuration cfg2 = createConfiguration(); InfinispanRegionFactory regionFactory2 = CacheTestUtil.startRegionFactory( - new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), + new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(), cfg2, getCacheTestSupport() ); diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JBossStandaloneJtaExampleTest.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JBossStandaloneJtaExampleTest.java index bc6b699a1e..73e2388a78 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JBossStandaloneJtaExampleTest.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JBossStandaloneJtaExampleTest.java @@ -57,7 +57,7 @@ import org.hibernate.cfg.Environment; import org.hibernate.mapping.Collection; import org.hibernate.mapping.PersistentClass; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform; import org.hibernate.stat.Statistics; import org.hibernate.test.cache.infinispan.functional.Item; import org.hibernate.testing.ServiceRegistryBuilder; diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JtaPlatformImpl.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JtaPlatformImpl.java index 95db052882..20e0674c09 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JtaPlatformImpl.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JtaPlatformImpl.java @@ -31,7 +31,7 @@ import javax.transaction.UserTransaction; import org.hibernate.TransactionException; import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; /** * @author Steve Ebersole diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java index e0ec86a820..2be132d95c 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java @@ -27,7 +27,7 @@ import java.util.Properties; import org.hibernate.HibernateException; import org.hibernate.service.UnknownUnwrapTypeException; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.spi.Stoppable; import org.hibernate.testing.env.ConnectionProviderBuilder; diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeJtaPlatform.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeJtaPlatform.java index 6d6f75d17d..a53aced180 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeJtaPlatform.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeJtaPlatform.java @@ -34,7 +34,7 @@ import org.infinispan.transaction.tm.BatchModeTransactionManager; import org.hibernate.HibernateException; import org.hibernate.TransactionException; import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper; -import org.hibernate.service.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; /** * @author Steve Ebersole diff --git a/hibernate-proxool/src/main/java/org/hibernate/service/jdbc/connections/internal/ProxoolConnectionProvider.java b/hibernate-proxool/src/main/java/org/hibernate/service/jdbc/connections/internal/ProxoolConnectionProvider.java index 116116b5fc..a4ac220c2c 100644 --- a/hibernate-proxool/src/main/java/org/hibernate/service/jdbc/connections/internal/ProxoolConnectionProvider.java +++ b/hibernate-proxool/src/main/java/org/hibernate/service/jdbc/connections/internal/ProxoolConnectionProvider.java @@ -40,7 +40,7 @@ import org.hibernate.internal.util.ConfigHelper; import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.UnknownUnwrapTypeException; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; /** * A connection provider that uses a Proxool connection pool. Hibernate will use this by diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java b/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java index 902d14ce91..efab4e2d63 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java @@ -25,9 +25,10 @@ package org.hibernate.testing; import java.util.Map; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Environment; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; /** * @author Steve Ebersole @@ -38,7 +39,7 @@ public class ServiceRegistryBuilder { } public static StandardServiceRegistryImpl buildServiceRegistry(Map serviceRegistryConfig) { - return (StandardServiceRegistryImpl) new org.hibernate.service.ServiceRegistryBuilder() + return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings( serviceRegistryConfig ) .buildServiceRegistry(); } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java b/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java index 443a13a346..e7aef85b82 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java @@ -28,7 +28,7 @@ import java.util.Properties; import org.hibernate.cfg.Environment; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.H2Dialect; -import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl; +import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; /** * Defines the JDBC connection information (currently H2) used by Hibernate for unit (not functional!) tests diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/jta/JtaAwareConnectionProviderImpl.java b/hibernate-testing/src/main/java/org/hibernate/testing/jta/JtaAwareConnectionProviderImpl.java index 74ec5f1e1e..c429a64c39 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/jta/JtaAwareConnectionProviderImpl.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/jta/JtaAwareConnectionProviderImpl.java @@ -37,10 +37,9 @@ import java.util.Map; import java.util.Properties; import org.hibernate.cfg.Environment; -import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper; -import org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator; -import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl; -import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator; +import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.spi.Configurable; import org.hibernate.service.spi.Stoppable; diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/jta/TestingJtaPlatformImpl.java b/hibernate-testing/src/main/java/org/hibernate/testing/jta/TestingJtaPlatformImpl.java index 5cac046eb0..fc607fd48e 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/jta/TestingJtaPlatformImpl.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/jta/TestingJtaPlatformImpl.java @@ -32,10 +32,10 @@ import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean; import com.arjuna.ats.internal.arjuna.objectstore.VolatileStore; import com.arjuna.common.internal.util.propertyservice.BeanPopulator; -import org.hibernate.service.jta.platform.internal.AbstractJtaPlatform; -import org.hibernate.service.jta.platform.internal.JtaSynchronizationStrategy; -import org.hibernate.service.jta.platform.internal.SynchronizationRegistryAccess; -import org.hibernate.service.jta.platform.internal.SynchronizationRegistryBasedSynchronizationStrategy; +import org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.JtaSynchronizationStrategy; +import org.hibernate.engine.transaction.jta.platform.internal.SynchronizationRegistryAccess; +import org.hibernate.engine.transaction.jta.platform.internal.SynchronizationRegistryBasedSynchronizationStrategy; /** * A test-specific implementation of the JtaPlatform contract for testing JTA-based functionality. diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java index 02658301fe..e73668362c 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java @@ -40,6 +40,7 @@ import org.junit.Before; import org.hibernate.HibernateException; import org.hibernate.Interceptor; import org.hibernate.Session; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; @@ -58,12 +59,11 @@ import org.hibernate.mapping.Property; import org.hibernate.mapping.SimpleValue; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.source.MetadataImplementor; -import org.hibernate.service.BootstrapServiceRegistry; -import org.hibernate.service.BootstrapServiceRegistryBuilder; +import org.hibernate.boot.registry.BootstrapServiceRegistry; +import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.service.config.spi.ConfigurationService; -import org.hibernate.service.internal.StandardServiceRegistryImpl; +import org.hibernate.engine.config.spi.ConfigurationService; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.testing.AfterClassOnce; import org.hibernate.testing.BeforeClassOnce; import org.hibernate.testing.OnExpectedFailure; @@ -334,7 +334,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase { ConfigurationHelper.resolvePlaceHolders( properties ); final BootstrapServiceRegistry bootstrapServiceRegistry = generateBootstrapRegistry( properties ); - ServiceRegistryBuilder registryBuilder = new ServiceRegistryBuilder( bootstrapServiceRegistry ) + StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder( bootstrapServiceRegistry ) .applySettings( properties ); prepareBasicRegistryBuilder( registryBuilder ); return (StandardServiceRegistryImpl) registryBuilder.buildServiceRegistry(); @@ -349,7 +349,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase { protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) { } - protected void prepareBasicRegistryBuilder(ServiceRegistryBuilder serviceRegistryBuilder) { + protected void prepareBasicRegistryBuilder(StandardServiceRegistryBuilder serviceRegistryBuilder) { } protected void afterSessionFactoryBuilt() { From 37542fe1f17379ec3b4497a9736bcfca1b3cc488 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 29 Aug 2012 10:49:06 -0500 Subject: [PATCH 09/38] HHH-6823 - Short-name config values --- .../en-US/chapters/services/Services.xml | 49 ++- .../manual/en-US/content/architecture.xml | 17 +- .../manual/en-US/content/configuration.xml | 69 ---- .../internal/StrategySelectorBuilder.java | 217 ++++++++++- .../org/hibernate/cfg/AvailableSettings.java | 17 - .../dialect/internal/DialectFactoryImpl.java | 25 +- .../internal/JtaPlatformInitiator.java | 109 +----- .../TransactionManagerLookupBridge.java | 60 --- .../hibernate/internal/CoreMessageLogger.java | 12 +- .../org/hibernate/jmx/HibernateService.java | 200 ---------- .../hibernate/jmx/HibernateServiceMBean.java | 337 ---------------- .../org/hibernate/jmx/SessionFactoryStub.java | 258 ------------ .../org/hibernate/jmx/StatisticsService.java | 367 ------------------ .../hibernate/jmx/StatisticsServiceMBean.java | 20 - .../transaction/TransactionManagerLookup.java | 74 ---- .../org/hibernate/transaction/package.html | 35 -- .../dialect/resolver/DialectFactoryTest.java | 30 +- .../java/org/hibernate/jmx/Entity.hbm.xml | 15 - .../test/java/org/hibernate/jmx/Entity.java | 28 -- .../java/org/hibernate/jmx/TrivialTest.java | 56 --- .../DualNodeTransactionManagerLookup.java | 55 --- .../tm/JBossStandaloneJtaExampleTest.java | 59 +-- .../BatchModeTransactionManagerLookup.java | 61 --- 23 files changed, 300 insertions(+), 1870 deletions(-) delete mode 100644 hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerLookupBridge.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/jmx/HibernateServiceMBean.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/jmx/StatisticsService.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/jmx/StatisticsServiceMBean.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/transaction/TransactionManagerLookup.java delete mode 100755 hibernate-core/src/main/java/org/hibernate/transaction/package.html delete mode 100644 hibernate-core/src/test/java/org/hibernate/jmx/Entity.hbm.xml delete mode 100644 hibernate-core/src/test/java/org/hibernate/jmx/Entity.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/jmx/TrivialTest.java delete mode 100644 hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTransactionManagerLookup.java delete mode 100755 hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeTransactionManagerLookup.java diff --git a/documentation/src/main/docbook/devguide/en-US/chapters/services/Services.xml b/documentation/src/main/docbook/devguide/en-US/chapters/services/Services.xml index cb40a52da8..82c595d08a 100644 --- a/documentation/src/main/docbook/devguide/en-US/chapters/services/Services.xml +++ b/documentation/src/main/docbook/devguide/en-US/chapters/services/Services.xml @@ -408,11 +408,12 @@ - JtaPlatformInitiator provides mapping against the legacy, - now-deprecated org.hibernate.transaction.TransactionManagerLookup - names internally for the Hibernate-provided + As of 5.0 support has been completely removed for mapping against legacy org.hibernate.transaction.TransactionManagerLookup - implementations. + names and custom implementations. Applications implementing + org.hibernate.transaction.TransactionManagerLookup + or using the hibernate.transaction.manager_lookup_class setting + should update to use JtaPlatform. @@ -424,43 +425,50 @@ org.hibernate.engine.transaction.jta.platform.internal.BitronixJtaPlatform - - Integration with the Bitronix stand-alone transaction manager. + Integration with the Bitronix stand-alone transaction manager. Can also be referenced + using the Bitronix configuration short name org.hibernate.engine.transaction.jta.platform.internal.BorlandEnterpriseServerJtaPlatform - - Integration with the transaction manager as deployed within a Borland Enterprise Server + Integration with the transaction manager as deployed within a Borland Enterprise Server. + Can also be referenced using the Borland configuration short name org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform - - Integration with the transaction manager as deployed within a JBoss Application Server + Integration with the transaction manager as deployed within a JBoss Application Server. + Can also be referenced using the JBossAS configuration short name org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform - - Integration with the JBoss Transactions stand-alone transaction manager + Integration with the JBoss Transactions stand-alone transaction manager. + Can also be referenced using the JBossTS configuration short name org.hibernate.engine.transaction.jta.platform.internal.JOTMJtaPlatform - - Integration with the JOTM stand-alone transaction manager + Integration with the JOTM stand-alone transaction manager. Can also be referenced + using the JOTM configuration short name org.hibernate.engine.transaction.jta.platform.internal.JOnASJtaPlatform - - Integration with the JOnAS transaction manager. + Integration with the JOnAS transaction manager. Can also be referenced using the + JOnAS configuration short name org.hibernate.engine.transaction.jta.platform.internal.JRun4JtaPlatform - Integration with the transaction manager as deployed in a JRun 4 application server. + Can also be referenced using the JRun4 configuration short name @@ -473,6 +481,7 @@ org.hibernate.engine.transaction.jta.platform.internal.OC4JJtaPlatform - Integration with transaction manager as deployed in an OC4J (Oracle) application + Can also be referenced using the OC4J configuration short name server. @@ -480,47 +489,45 @@ org.hibernate.engine.transaction.jta.platform.internal.OrionJtaPlatform - Integration with transaction manager as deployed in an Orion application server. + Can also be referenced using the Orion configuration short name org.hibernate.engine.transaction.jta.platform.internal.ResinJtaPlatform - Integration with transaction manager as deployed in a Resin application server. + Can also be referenced using the Resin configuration short name org.hibernate.engine.transaction.jta.platform.internal.SunOneJtaPlatform - Integration with transaction manager as deployed in a Sun ONE (7 and above) - application server. - - - - - org.hibernate.engine.transaction.jta.platform.internal.TransactionManagerLookupBridge - - Provides a bridge to legacy (and deprecated) - org.hibernate.transaction.TransactionManagerLookup - implementations + application server. Can also be referenced using the SunOne + configuration short name org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform - Integration with transaction manager as deployed in a WebSphere Application Server - (6 and above). + (6 and above). Can also be referenced using the WebSphereExtended + configuration short name org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform - Integration with transaction manager as deployed in a WebSphere Application Server - (4, 5.0 and 5.1). + (4, 5.0 and 5.1). Can also be referenced using the WebSphere + configuration short name org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform - Integration with transaction manager as deployed in a Weblogic application server. + Can also be referenced using the Weblogic configuration short name diff --git a/documentation/src/main/docbook/manual/en-US/content/architecture.xml b/documentation/src/main/docbook/manual/en-US/content/architecture.xml index 4fb389482b..f9ad0e2e27 100644 --- a/documentation/src/main/docbook/manual/en-US/content/architecture.xml +++ b/documentation/src/main/docbook/manual/en-US/content/architecture.xml @@ -167,21 +167,6 @@

    -
    - JMX Integration - - - JMX is the J2EE standard for the management of Java components. Hibernate can be managed via - a JMX standard service. AN MBean implementation is provided in the distribution: - org.hibernate.jmx.HibernateService. - - - - Another feature available as a JMX service is runtime Hibernate statistics. See - for more information. - -
    -
    Contextual sessions @@ -259,7 +244,7 @@ The hibernate.current_session_context_class configuration parameter defines which org.hibernate.context.spi.CurrentSessionContext implementation should be used. For backwards compatibility, if this configuration parameter is not set - but a org.hibernate.transaction.TransactionManagerLookup is configured, + but a org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform is configured, Hibernate will use the org.hibernate.context.internal.JTASessionContext. Typically, the value of this parameter would just name the implementation class to use. For the three out-of-the-box implementations, however, there are three corresponding diff --git a/documentation/src/main/docbook/manual/en-US/content/configuration.xml b/documentation/src/main/docbook/manual/en-US/content/configuration.xml index 7532bb94a3..7b40758ff5 100644 --- a/documentation/src/main/docbook/manual/en-US/content/configuration.xml +++ b/documentation/src/main/docbook/manual/en-US/content/configuration.xml @@ -1734,74 +1734,5 @@ hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect transaction demarcation with CMT is preferred.
    -
    - JMX deployment - - The line cfg.buildSessionFactory() still has to - be executed somewhere to get a SessionFactory into - JNDI. You can do this either in a static initializer - block, like the one in HibernateUtil, or you can - deploy Hibernate as a managed service. - - Hibernate is distributed with - org.hibernate.jmx.HibernateService for deployment on - an application server with JMX capabilities, such as JBoss AS. The - actual deployment and configuration is vendor-specific. Here is an - example jboss-service.xml for JBoss 4.0.x: - - <?xml version="1.0"?> -<server> - -<mbean code="org.hibernate.jmx.HibernateService" - name="jboss.jca:service=HibernateFactory,name=HibernateFactory"> - - <!-- Required services --> - <depends>jboss.jca:service=RARDeployer</depends> - <depends>jboss.jca:service=LocalTxCM,name=HsqlDS</depends> - - <!-- Bind the Hibernate service to JNDI --> - <attribute name="JndiName">java:/hibernate/SessionFactory</attribute> - - <!-- Datasource settings --> - <attribute name="Datasource">java:HsqlDS</attribute> - <attribute name="Dialect">org.hibernate.dialect.HSQLDialect</attribute> - - <!-- Transaction integration --> - <attribute name="TransactionStrategy"> - org.hibernate.transaction.JTATransactionFactory</attribute> - <attribute name="TransactionManagerLookupStrategy"> - org.hibernate.transaction.JBossTransactionManagerLookup</attribute> - <attribute name="FlushBeforeCompletionEnabled">true</attribute> - <attribute name="AutoCloseSessionEnabled">true</attribute> - - <!-- Fetching options --> - <attribute name="MaximumFetchDepth">5</attribute> - - <!-- Second-level caching --> - <attribute name="SecondLevelCacheEnabled">true</attribute> - <attribute name="CacheProviderClass">org.hibernate.cache.internal.EhCacheProvider</attribute> - <attribute name="QueryCacheEnabled">true</attribute> - - <!-- Logging --> - <attribute name="ShowSqlEnabled">true</attribute> - - <!-- Mapping files --> - <attribute name="MapResources">auction/Item.hbm.xml,auction/Category.hbm.xml</attribute> - -</mbean> - -</server> - - This file is deployed in a directory called - META-INF and packaged in a JAR file with the - extension .sar (service archive). You also need to - package Hibernate, its required third-party libraries, your compiled - persistent classes, as well as your mapping files in the same archive. - Your enterprise beans (usually session beans) can be kept in their own - JAR file, but you can include this EJB JAR file in the main service - archive to get a single (hot-)deployable unit. Consult the JBoss AS - documentation for more information about JMX service and EJB - deployment. -
    diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java index 1cce52e67b..b2480a90ac 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java @@ -28,13 +28,69 @@ import java.util.List; import org.jboss.logging.Logger; -import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory; -import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; -import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory; -import org.hibernate.engine.transaction.spi.TransactionFactory; import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl; import org.hibernate.boot.registry.selector.spi.StrategySelectionException; import org.hibernate.boot.registry.selector.spi.StrategySelector; +import org.hibernate.dialect.CUBRIDDialect; +import org.hibernate.dialect.Cache71Dialect; +import org.hibernate.dialect.DB2390Dialect; +import org.hibernate.dialect.DB2400Dialect; +import org.hibernate.dialect.DB2Dialect; +import org.hibernate.dialect.DerbyTenFiveDialect; +import org.hibernate.dialect.DerbyTenSevenDialect; +import org.hibernate.dialect.DerbyTenSixDialect; +import org.hibernate.dialect.Dialect; +import org.hibernate.dialect.FirebirdDialect; +import org.hibernate.dialect.FrontBaseDialect; +import org.hibernate.dialect.H2Dialect; +import org.hibernate.dialect.HSQLDialect; +import org.hibernate.dialect.InformixDialect; +import org.hibernate.dialect.Ingres10Dialect; +import org.hibernate.dialect.Ingres9Dialect; +import org.hibernate.dialect.IngresDialect; +import org.hibernate.dialect.InterbaseDialect; +import org.hibernate.dialect.JDataStoreDialect; +import org.hibernate.dialect.MckoiDialect; +import org.hibernate.dialect.MimerSQLDialect; +import org.hibernate.dialect.MySQL5Dialect; +import org.hibernate.dialect.MySQL5InnoDBDialect; +import org.hibernate.dialect.Oracle10gDialect; +import org.hibernate.dialect.Oracle8iDialect; +import org.hibernate.dialect.Oracle9iDialect; +import org.hibernate.dialect.PointbaseDialect; +import org.hibernate.dialect.PostgreSQL81Dialect; +import org.hibernate.dialect.PostgreSQL82Dialect; +import org.hibernate.dialect.PostgresPlusDialect; +import org.hibernate.dialect.ProgressDialect; +import org.hibernate.dialect.SAPDBDialect; +import org.hibernate.dialect.SQLServer2005Dialect; +import org.hibernate.dialect.SQLServer2008Dialect; +import org.hibernate.dialect.SQLServerDialect; +import org.hibernate.dialect.Sybase11Dialect; +import org.hibernate.dialect.SybaseASE157Dialect; +import org.hibernate.dialect.SybaseASE15Dialect; +import org.hibernate.dialect.SybaseAnywhereDialect; +import org.hibernate.dialect.TeradataDialect; +import org.hibernate.dialect.TimesTenDialect; +import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory; +import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; +import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory; +import org.hibernate.engine.transaction.jta.platform.internal.BitronixJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.BorlandEnterpriseServerJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.JOTMJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.JOnASJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.JRun4JtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.OC4JJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.OrionJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.ResinJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.SunOneJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; +import org.hibernate.engine.transaction.spi.TransactionFactory; /** * @author Steve Ebersole @@ -80,6 +136,8 @@ public class StrategySelectorBuilder { StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService ); // build the baseline... + addDialects( strategySelector ); + addJtaPlatforms( strategySelector ); addTransactionFactories( strategySelector ); // todo : apply auto-discovered registrations @@ -92,6 +150,157 @@ public class StrategySelectorBuilder { return strategySelector; } + private void addDialects(StrategySelectorImpl strategySelector) { + strategySelector.registerStrategyImplementor( Dialect.class, "Cache71", Cache71Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "CUBRID", CUBRIDDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "DB2", DB2Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "DB2-390", DB2390Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "DB2-400", DB2400Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Derby10.5", DerbyTenFiveDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Derby10.6", DerbyTenSixDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Derby10.7", DerbyTenSevenDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Firebird", FirebirdDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "FrontBase", FrontBaseDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "H2", H2Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "HSQL", HSQLDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Informix", InformixDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Ingres", IngresDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Ingres9", Ingres9Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Ingres10", Ingres10Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Interbase", InterbaseDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "JDataStore", JDataStoreDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Mckoi", MckoiDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "MimerSQL", MimerSQLDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "MySQL5", MySQL5Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "MySQL5-InnoDB", MySQL5InnoDBDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "MySQL", MySQL5Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "MySQL-InnoDB", MySQL5InnoDBDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Oracle8i", Oracle8iDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Oracle9i", Oracle9iDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Oracle10g", Oracle10gDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Pointbase", PointbaseDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "PostgresPlus", PostgresPlusDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "PostgreSQL81", PostgreSQL81Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "PostgreSQL82", PostgreSQL82Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Progress", ProgressDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "SAP", SAPDBDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "SQLServer", SQLServerDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "SQLServer2005", SQLServer2005Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "SQLServer2008", SQLServer2008Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Sybase11", Sybase11Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "SybaseAnywhere", SybaseAnywhereDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "SybaseASE15", SybaseASE15Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "SybaseASE157", SybaseASE157Dialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "Teradata", TeradataDialect.class ); + strategySelector.registerStrategyImplementor( Dialect.class, "TimesTen", TimesTenDialect.class ); + } + + private void addJtaPlatforms(StrategySelectorImpl strategySelector) { + addJtaPlatforms( + strategySelector, + BorlandEnterpriseServerJtaPlatform.class, + "Borland", + "org.hibernate.service.jta.platform.internal.BorlandEnterpriseServerJtaPlatform" + ); + + addJtaPlatforms( + strategySelector, + BitronixJtaPlatform.class, + "Bitronix", + "org.hibernate.service.jta.platform.internal.BitronixJtaPlatform" + ); + + addJtaPlatforms( + strategySelector, + JBossAppServerJtaPlatform.class, + "JBossAS", + "org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" + ); + + addJtaPlatforms( + strategySelector, + JBossStandAloneJtaPlatform.class, + "JBossTS", + "org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform" + ); + + addJtaPlatforms( + strategySelector, + JOnASJtaPlatform.class, + "JOnAS", + "org.hibernate.service.jta.platform.internal.JOnASJtaPlatform" + ); + + addJtaPlatforms( + strategySelector, + JOTMJtaPlatform.class, + "JOTM", + "org.hibernate.service.jta.platform.internal.JOTMJtaPlatform" + ); + + addJtaPlatforms( + strategySelector, + JRun4JtaPlatform.class, + "JRun4", + "org.hibernate.service.jta.platform.internal.JRun4JtaPlatform" + ); + + addJtaPlatforms( + strategySelector, + OC4JJtaPlatform.class, + "OC4J", + "org.hibernate.service.jta.platform.internal.OC4JJtaPlatform" + ); + + addJtaPlatforms( + strategySelector, + OrionJtaPlatform.class, + "Orion", + "org.hibernate.service.jta.platform.internal.OrionJtaPlatform" + ); + + addJtaPlatforms( + strategySelector, + ResinJtaPlatform.class, + "Resin", + "org.hibernate.service.jta.platform.internal.ResinJtaPlatform" + ); + + addJtaPlatforms( + strategySelector, + SunOneJtaPlatform.class, + "SunOne", + "org.hibernate.service.jta.platform.internal.SunOneJtaPlatform" + ); + + addJtaPlatforms( + strategySelector, + WeblogicJtaPlatform.class, + "Weblogic", + "org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform" + ); + + addJtaPlatforms( + strategySelector, + WebSphereJtaPlatform.class, + "WebSphere", + "org.hibernate.service.jta.platform.internal.WebSphereJtaPlatform" + ); + + addJtaPlatforms( + strategySelector, + WebSphereExtendedJtaPlatform.class, + "WebSphereExtended", + "org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform" + ); + } + + private void addJtaPlatforms(StrategySelectorImpl strategySelector, Class impl, String... names) { + for ( String name : names ) { + strategySelector.registerStrategyImplementor( JtaPlatform.class, name, impl ); + } + } + private void addTransactionFactories(StrategySelectorImpl strategySelector) { strategySelector.registerStrategyImplementor( TransactionFactory.class, JdbcTransactionFactory.SHORT_NAME, JdbcTransactionFactory.class ); strategySelector.registerStrategyImplementor( TransactionFactory.class, "org.hibernate.transaction.JDBCTransactionFactory", JdbcTransactionFactory.class ); diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java index 351d2600e3..74f75967ee 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java @@ -282,23 +282,6 @@ public interface AvailableSettings { */ public static final String JTA_PLATFORM = "hibernate.transaction.jta.platform"; - /** - * Names the {@link org.hibernate.transaction.TransactionManagerLookup} implementation to use for obtaining - * reference to the {@literal JTA} {@link javax.transaction.TransactionManager} - * - * @deprecated See {@link #JTA_PLATFORM} - */ - @Deprecated - public static final String TRANSACTION_MANAGER_STRATEGY = "hibernate.transaction.manager_lookup_class"; - - /** - * JNDI name of JTA UserTransaction object - * - * @deprecated See {@link #JTA_PLATFORM} - */ - @Deprecated - public static final String USER_TRANSACTION = "jta.UserTransaction"; - /** * The {@link org.hibernate.cache.spi.RegionFactory} implementation class */ diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java index a140f381b5..b5ee361502 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java @@ -29,10 +29,9 @@ import java.sql.SQLException; import java.util.Map; import org.hibernate.HibernateException; +import org.hibernate.boot.registry.selector.spi.StrategySelector; import org.hibernate.cfg.AvailableSettings; import org.hibernate.dialect.Dialect; -import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; -import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.engine.jdbc.dialect.spi.DialectFactory; import org.hibernate.engine.jdbc.dialect.spi.DialectResolver; import org.hibernate.service.spi.InjectService; @@ -43,11 +42,11 @@ import org.hibernate.service.spi.InjectService; * @author Steve Ebersole */ public class DialectFactoryImpl implements DialectFactory { - private ClassLoaderService classLoaderService; + private StrategySelector strategySelector; @InjectService - public void setClassLoaderService(ClassLoaderService classLoaderService) { - this.classLoaderService = classLoaderService; + public void setStrategySelector(StrategySelector strategySelector) { + this.strategySelector = strategySelector; } private DialectResolver dialectResolver; @@ -69,17 +68,19 @@ public class DialectFactoryImpl implements DialectFactory { } private Dialect constructDialect(String dialectName) { + final Dialect dialect; try { - return ( Dialect ) classLoaderService.classForName( dialectName ).newInstance(); + dialect = strategySelector.resolveStrategy( Dialect.class, dialectName ); + if ( dialect == null ) { + throw new HibernateException( "Unable to construct requested dialect [" + dialectName+ "]" ); + } + return dialect; } - catch ( ClassLoadingException e ) { - throw new HibernateException( "Dialect class not found: " + dialectName, e ); - } - catch ( HibernateException e ) { + catch (HibernateException e) { throw e; } - catch ( Exception e ) { - throw new HibernateException( "Could not instantiate dialect class", e ); + catch (Exception e) { + throw new HibernateException( "Unable to construct requested dialect [" + dialectName+ "]", e ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java index d5439a21aa..db46f082e4 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java @@ -28,16 +28,11 @@ import java.util.Map; import org.jboss.logging.Logger; import org.hibernate.boot.registry.StandardServiceInitiator; +import org.hibernate.boot.registry.selector.spi.StrategySelector; import org.hibernate.cfg.AvailableSettings; -import org.hibernate.cfg.Environment; -import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.internal.util.jndi.JndiHelper; -import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; -import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; -import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException; +import org.hibernate.internal.CoreMessageLogger; import org.hibernate.service.spi.ServiceRegistryImplementor; -import org.hibernate.transaction.TransactionManagerLookup; /** * Standard initiator for the standard {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} @@ -57,106 +52,12 @@ public class JtaPlatformInitiator implements StandardServiceInitiator %s", transactionManagerLookupImplName, platform); - } - } return platform; } - - private JtaPlatform mapLegacyClasses(String tmlImplName, Map configVales, ServiceRegistryImplementor registry) { - if ( tmlImplName == null ) { - return null; - } - - LOG.legacyTransactionManagerStrategy(JtaPlatform.class.getName(), AvailableSettings.JTA_PLATFORM); - - if ( "org.hibernate.transaction.BESTransactionManagerLookup".equals( tmlImplName ) ) { - return new BorlandEnterpriseServerJtaPlatform(); - } - - if ( "org.hibernate.transaction.BTMTransactionManagerLookup".equals( tmlImplName ) ) { - return new BitronixJtaPlatform(); - } - - if ( "org.hibernate.transaction.JBossTransactionManagerLookup".equals( tmlImplName ) ) { - return new JBossAppServerJtaPlatform(); - } - - if ( "org.hibernate.transaction.JBossTSStandaloneTransactionManagerLookup".equals( tmlImplName ) ) { - return new JBossStandAloneJtaPlatform(); - } - - if ( "org.hibernate.transaction.JOnASTransactionManagerLookup".equals( tmlImplName ) ) { - return new JOnASJtaPlatform(); - } - - if ( "org.hibernate.transaction.JOTMTransactionManagerLookup".equals( tmlImplName ) ) { - return new JOTMJtaPlatform(); - } - - if ( "org.hibernate.transaction.JRun4TransactionManagerLookup".equals( tmlImplName ) ) { - return new JRun4JtaPlatform(); - } - - if ( "org.hibernate.transaction.OC4JTransactionManagerLookup".equals( tmlImplName ) ) { - return new OC4JJtaPlatform(); - } - - if ( "org.hibernate.transaction.OrionTransactionManagerLookup".equals( tmlImplName ) ) { - return new OrionJtaPlatform(); - } - - if ( "org.hibernate.transaction.ResinTransactionManagerLookup".equals( tmlImplName ) ) { - return new ResinJtaPlatform(); - } - - if ( "org.hibernate.transaction.SunONETransactionManagerLookup".equals( tmlImplName ) ) { - return new SunOneJtaPlatform(); - } - - if ( "org.hibernate.transaction.WeblogicTransactionManagerLookup".equals( tmlImplName ) ) { - return new WeblogicJtaPlatform(); - } - - if ( "org.hibernate.transaction.WebSphereTransactionManagerLookup".equals( tmlImplName ) ) { - return new WebSphereJtaPlatform(); - } - - if ( "org.hibernate.transaction.WebSphereExtendedJTATransactionLookup".equals( tmlImplName ) ) { - return new WebSphereExtendedJtaPlatform(); - } - - try { - TransactionManagerLookup lookup = (TransactionManagerLookup) registry.getService( ClassLoaderService.class ) - .classForName( tmlImplName ) - .newInstance(); - return new TransactionManagerLookupBridge( lookup, JndiHelper.extractJndiProperties( configVales ) ); - } - catch ( Exception e ) { - throw new JtaPlatformException( - "Unable to build " + TransactionManagerLookupBridge.class.getName() + " from specified " + - TransactionManagerLookup.class.getName() + " implementation: " + - tmlImplName - ); - } - } } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerLookupBridge.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerLookupBridge.java deleted file mode 100644 index 7664dd6e5b..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerLookupBridge.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2011, 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 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 - * 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.engine.transaction.jta.platform.internal; - -import java.util.Properties; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; -import javax.transaction.UserTransaction; - -import org.hibernate.engine.jndi.spi.JndiService; -import org.hibernate.transaction.TransactionManagerLookup; - -/** - * @author Steve Ebersole - */ -public class TransactionManagerLookupBridge extends AbstractJtaPlatform { - private final TransactionManagerLookup lookup; - private final Properties jndiProperties; - - public TransactionManagerLookupBridge(TransactionManagerLookup lookup, Properties jndiProperties) { - this.lookup = lookup; - this.jndiProperties = jndiProperties; - } - - @Override - protected TransactionManager locateTransactionManager() { - return lookup.getTransactionManager( jndiProperties ); - } - - @Override - protected UserTransaction locateUserTransaction() { - return (UserTransaction) serviceRegistry().getService( JndiService.class ).locate( lookup.getUserTransactionName() ); - } - - @Override - public Object getTransactionIdentifier(Transaction transaction) { - return lookup.getTransactionIdentifier( transaction ); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java index 8f2daf2efc..e01390290b 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java @@ -1501,12 +1501,12 @@ public interface CoreMessageLogger extends BasicLogger { @Message(value = "You should set hibernate.transaction.manager_lookup_class if cache is enabled", id = 426) void setManagerLookupClass(); - @LogMessage(level = WARN) - @Message(value = "Using deprecated %s strategy [%s], use newer %s strategy instead [%s]", id = 427) - void deprecatedTransactionManagerStrategy(String name, - String transactionManagerStrategy, - String name2, - String jtaPlatform); +// @LogMessage(level = WARN) +// @Message(value = "Using deprecated %s strategy [%s], use newer %s strategy instead [%s]", id = 427) +// void deprecatedTransactionManagerStrategy(String name, +// String transactionManagerStrategy, +// String name2, +// String jtaPlatform); @LogMessage(level = INFO) @Message(value = "Encountered legacy TransactionManagerLookup specified; convert to newer %s contract specified via %s setting", diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java b/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java deleted file mode 100644 index 666c1be0a9..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java +++ /dev/null @@ -1,200 +0,0 @@ -//$Id: HibernateService.java 6100 2005-03-17 10:48:03Z turin42 $ -package org.hibernate.jmx; - -import java.util.Map; -import java.util.Properties; -import javax.naming.InitialContext; - -import org.jboss.logging.Logger; - -import org.hibernate.HibernateException; -import org.hibernate.SessionFactory; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import org.hibernate.cfg.AvailableSettings; -import org.hibernate.cfg.Environment; -import org.hibernate.cfg.ExternalSessionFactoryConfig; -import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.internal.util.jndi.JndiHelper; -import org.hibernate.tool.hbm2ddl.SchemaExport; - - -/** - * Implementation of HibernateServiceMBean. Creates a - * SessionFactory and binds it to the specified JNDI name.
    - *
    - * All mapping documents are loaded as resources by the MBean. - * @see HibernateServiceMBean - * @see org.hibernate.SessionFactory - * @author John Urberg, Gavin King - * @deprecated See HHH-6190 for details - */ -@Deprecated -public class HibernateService extends ExternalSessionFactoryConfig implements HibernateServiceMBean { - - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, HibernateService.class.getName()); - - private String boundName; - private Properties properties = new Properties(); - - @Override - public void start() throws HibernateException { - boundName = getJndiName(); - try { - buildSessionFactory(); - } - catch (HibernateException he) { - LOG.unableToBuildSessionFactoryUsingMBeanClasspath(he.getMessage()); - LOG.debug("Error was", he); - new SessionFactoryStub(this); - } - } - - @Override - public void stop() { - LOG.stoppingService(); - try { - InitialContext context = JndiHelper.getInitialContext( buildProperties() ); - ( (SessionFactory) context.lookup(boundName) ).close(); - //context.unbind(boundName); - } - catch (Exception e) { - LOG.unableToStopHibernateService(e); - } - } - - SessionFactory buildSessionFactory() throws HibernateException { - LOG.startingServiceAtJndiName( boundName ); - LOG.serviceProperties( properties ); - return buildConfiguration().buildSessionFactory( - new StandardServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry() - ); - } - - @Override - protected Map getExtraProperties() { - return properties; - } - - @Override - public String getTransactionStrategy() { - return getProperty(Environment.TRANSACTION_STRATEGY); - } - - @Override - public void setTransactionStrategy(String txnStrategy) { - setProperty(Environment.TRANSACTION_STRATEGY, txnStrategy); - } - - @Override - public String getUserTransactionName() { - return getProperty(Environment.USER_TRANSACTION); - } - - @Override - public void setUserTransactionName(String utName) { - setProperty(Environment.USER_TRANSACTION, utName); - } - - @Override - public String getJtaPlatformName() { - return getProperty( AvailableSettings.JTA_PLATFORM ); - } - - @Override - public void setJtaPlatformName(String name) { - setProperty( AvailableSettings.JTA_PLATFORM, name ); - } - - @Override - public String getPropertyList() { - return buildProperties().toString(); - } - - @Override - public String getProperty(String property) { - return properties.getProperty(property); - } - - @Override - public void setProperty(String property, String value) { - properties.setProperty(property, value); - } - - @Override - public void dropSchema() { - new SchemaExport( buildConfiguration() ).drop(false, true); - } - - @Override - public void createSchema() { - new SchemaExport( buildConfiguration() ).create(false, true); - } - - public String getName() { - return getProperty(Environment.SESSION_FACTORY_NAME); - } - - @Override - public String getDatasource() { - return getProperty(Environment.DATASOURCE); - } - - @Override - public void setDatasource(String datasource) { - setProperty(Environment.DATASOURCE, datasource); - } - - @Override - public String getJndiName() { - return getProperty(Environment.SESSION_FACTORY_NAME); - } - - @Override - public void setJndiName(String jndiName) { - setProperty(Environment.SESSION_FACTORY_NAME, jndiName); - } - - @Override - public String getUserName() { - return getProperty(Environment.USER); - } - - @Override - public void setUserName(String userName) { - setProperty(Environment.USER, userName); - } - - @Override - public String getPassword() { - return getProperty(Environment.PASS); - } - - @Override - public void setPassword(String password) { - setProperty(Environment.PASS, password); - } - - @Override - public void setFlushBeforeCompletionEnabled(String enabled) { - setProperty(Environment.FLUSH_BEFORE_COMPLETION, enabled); - } - - @Override - public String getFlushBeforeCompletionEnabled() { - return getProperty(Environment.FLUSH_BEFORE_COMPLETION); - } - - @Override - public void setAutoCloseSessionEnabled(String enabled) { - setProperty(Environment.AUTO_CLOSE_SESSION, enabled); - } - - @Override - public String getAutoCloseSessionEnabled() { - return getProperty(Environment.AUTO_CLOSE_SESSION); - } - - public Properties getProperties() { - return buildProperties(); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateServiceMBean.java b/hibernate-core/src/main/java/org/hibernate/jmx/HibernateServiceMBean.java deleted file mode 100644 index 25db707ede..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateServiceMBean.java +++ /dev/null @@ -1,337 +0,0 @@ -//$Id: HibernateServiceMBean.java 10860 2006-11-22 00:02:55Z steve.ebersole@jboss.com $ -package org.hibernate.jmx; -import org.hibernate.HibernateException; - -/** - * Hibernate JMX Management API - * @see HibernateService - * @author John Urberg, Gavin King - * @deprecated See HHH-6190 for details - */ -@Deprecated -public interface HibernateServiceMBean { - - /** - * The Hibernate mapping files (might be overridden by subclasses - * that want to specify the mapping files by some other mechanism) - * @return String - */ - public String getMapResources(); - /** - * Specify the Hibernate mapping files - * @param mappingFiles - */ - public void setMapResources(String mappingFiles); - /** - * Add a mapping file - * @param mapResource - */ - public void addMapResource(String mapResource); - - /** - * Set a property - * @param property the property name - * @param value the property value - */ - public void setProperty(String property, String value); - - /** - * Get a property - * @param property the property name - * @return the property value - */ - public String getProperty(String property); - - /** - * Display the properties - * @return a list of property names and values - */ - public String getPropertyList(); - - /** - * The JNDI name of the datasource to use in this SessionFactory - * @return String - */ - public String getDatasource(); - /** - * Set the JNDI name of the datasource to use in this SessionFactory - * @param datasource - */ - public void setDatasource(String datasource); - - /** - * Log into the database with this name - * @return String - */ - public String getUserName(); - /** - * Log into the database with this name - * @param userName - */ - public void setUserName(String userName); - - /** - * Log into the database with this password - * @return String - */ - public String getPassword(); - /** - * Log into the database with this password - * @param password - */ - public void setPassword(String password); - - /** - * The JNDI name of the dialect class to use in this SessionFactory - * @return String - */ - public String getDialect(); - /** - * The name of the dialect class to use in this SessionFactory - * @param dialect fully qualified class name of Dialect subclass - * @see org.hibernate.dialect.Dialect - */ - public void setDialect(String dialect); - - /** - * The JNDI name to bind to the SessionFactory - * @return String - */ - public String getJndiName(); - /** - * The JNDI name to bind to the SessionFactory - * @param jndiName - */ - public void setJndiName(String jndiName); - - /** - * The fully qualified class name of the Hibernate {@link org.hibernate.engine.transaction.spi.TransactionFactory} - * implementation to use - * - * @return the class name - */ - public String getTransactionStrategy(); - - /** - * Set the fully qualified class name of the Hibernate {@link org.hibernate.engine.transaction.spi.TransactionFactory} - * implementation to use. - * - * @param txnStrategy the class name - */ - public void setTransactionStrategy(String txnStrategy); - - /** - * The JNDI name of the JTA UserTransaction object (used only be JtaTransaction). - * @return the JNDI name - * @see org.hibernate.engine.transaction.internal.jta.JtaTransaction - */ - public String getUserTransactionName(); - /** - * Set the JNDI name of the JTA UserTransaction object (used only by JtaTransaction). - * @param utName the JNDI name - * @see org.hibernate.engine.transaction.internal.jta.JtaTransaction - */ - public void setUserTransactionName(String utName); - - /** - * Get the name of the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation to use. - * - * @return The name of the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation to use. - */ - public String getJtaPlatformName(); - - /** - * Sets the name of the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation to use. - * - * @param name The implementation class name. - */ - public void setJtaPlatformName(String name); - - /** - * Is SQL logging enabled? - */ - public String getShowSqlEnabled(); - /** - * Enable logging of SQL to console - */ - public void setShowSqlEnabled(String showSql); - /** - * Get the maximum outer join fetch depth - */ - public String getMaximumFetchDepth(); - /** - * Set the maximum outer join fetch depth - */ - public void setMaximumFetchDepth(String fetchDepth); - /** - * Get the maximum JDBC batch size - */ - public String getJdbcBatchSize(); - /** - * Set the maximum JDBC batch size - */ - public void setJdbcBatchSize(String batchSize); - /** - * Get the JDBC fetch size - */ - public String getJdbcFetchSize(); - /** - * Set the JDBC fetch size - */ - public void setJdbcFetchSize(String fetchSize); - /** - * Get the query language substitutions - */ - public String getQuerySubstitutions(); - /** - * Set the query language substitutions - */ - public void setQuerySubstitutions(String querySubstitutions); - /** - * Get the default schema - */ - public String getDefaultSchema(); - /** - * Set the default schema - */ - public void setDefaultSchema(String schema); - /** - * Get the default catalog - */ - public String getDefaultCatalog(); - /** - * Set the default catalog - */ - public void setDefaultCatalog(String catalog); - /** - * Is use of scrollable resultsets enabled? - */ - public String getJdbcScrollableResultSetEnabled(); - /** - * Enable or disable the use of scrollable resultsets - */ - public void setJdbcScrollableResultSetEnabled(String enabled); - /** - * Is use of JDBC3 getGeneratedKeys() enabled? - */ - public String getGetGeneratedKeysEnabled(); - /** - * Enable or disable the use getGeneratedKeys() - */ - public void setGetGeneratedKeysEnabled(String enabled); - /** - * Get the second-level cache provider class name - */ - public String getCacheRegionFactory(); - /** - * Set the second-level cache provider class name - */ - public void setCacheRegionFactory(String cacheRegionFactory); - /** - * For cache providers which support this setting, get the - * provider's specific configuration resource. - */ - public String getCacheProviderConfig(); - /** - * For cache providers which support this setting, specify the - * provider's specific configuration resource. - */ - public void setCacheProviderConfig(String cacheProviderConfig); - /** - * Is the query cache enabled? - */ - public String getQueryCacheEnabled(); - /** - * Enable or disable the query cache - */ - public void setQueryCacheEnabled(String enabled); - /** - * Is the second-level cache enabled? - */ - public String getSecondLevelCacheEnabled(); - /** - * Enable or disable the second-level cache - */ - public void setSecondLevelCacheEnabled(String enabled); - /** - * Get the cache region prefix - */ - public String getCacheRegionPrefix(); - /** - * Set the cache region prefix - */ - public void setCacheRegionPrefix(String prefix); - /** - * Is the second-level cache optimized for miminal puts? - */ - public String getMinimalPutsEnabled(); - /** - * Enable or disable optimization of second-level cache - * for minimal puts - */ - public void setMinimalPutsEnabled(String enabled); - /** - * Are SQL comments enabled? - */ - public String getCommentsEnabled(); - /** - * Enable or disable the inclusion of comments in - * generated SQL - */ - public void setCommentsEnabled(String enabled); - /** - * Is JDBC batch update for versioned entities enabled? - */ - public String getBatchVersionedDataEnabled(); - /** - * Enable or disable the use of batch updates for - * versioned entities - */ - public void setBatchVersionedDataEnabled(String enabled); - - /** - * Enable automatic flushing of the Session when JTA transaction ends. - */ - public void setFlushBeforeCompletionEnabled(String enabled); - /** - * Is automatic Session flusing enabled? - */ - public String getFlushBeforeCompletionEnabled(); - - /** - * Enable automatic closing of Session when JTA transaction ends. - */ - public void setAutoCloseSessionEnabled(String enabled); - /** - * Is automatic Session closing enabled? - */ - public String getAutoCloseSessionEnabled(); - - /** - * Export the CREATE DDL to the database - * @throws HibernateException - */ - public void createSchema() throws HibernateException; - /** - * Export the DROP DDL to the database - * @throws HibernateException - */ - public void dropSchema() throws HibernateException; - - - /** - * Create the SessionFactory and bind to the jndi name on startup - */ - public void start() throws HibernateException; - /** - * Unbind the SessionFactory or stub from JNDI - */ - public void stop(); - -} - - - - - - diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java b/hibernate-core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java deleted file mode 100644 index 974277ebee..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, 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 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 - * 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.jmx; - -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; -import java.io.Serializable; -import java.sql.Connection; -import java.util.Map; -import java.util.Set; -import javax.naming.NamingException; -import javax.naming.Reference; -import javax.naming.StringRefAddr; - -import org.jboss.logging.Logger; - -import org.hibernate.AssertionFailure; -import org.hibernate.Cache; -import org.hibernate.HibernateException; -import org.hibernate.Session; -import org.hibernate.SessionBuilder; -import org.hibernate.SessionFactory; -import org.hibernate.StatelessSession; -import org.hibernate.StatelessSessionBuilder; -import org.hibernate.TypeHelper; -import org.hibernate.cfg.AvailableSettings; -import org.hibernate.engine.spi.FilterDefinition; -import org.hibernate.id.IdentifierGenerator; -import org.hibernate.id.UUIDGenerator; -import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.internal.SessionFactoryRegistry; -import org.hibernate.internal.util.config.ConfigurationHelper; -import org.hibernate.metadata.ClassMetadata; -import org.hibernate.metadata.CollectionMetadata; -import org.hibernate.engine.jndi.internal.JndiServiceImpl; -import org.hibernate.stat.Statistics; - -/** - * A flyweight for SessionFactory. If the MBean itself does not - * have classpath to the persistent classes, then a stub will be registered - * with JNDI and the actual SessionFactoryImpl built upon first - * access. - * - * @author Gavin King - * - * @deprecated See HHH-6190 for details - */ -@Deprecated -@SuppressWarnings( {"deprecation"}) -public class SessionFactoryStub implements SessionFactory { - private static final IdentifierGenerator UUID_GENERATOR = UUIDGenerator.buildSessionFactoryUniqueIdentifierGenerator(); - - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, SessionFactoryStub.class.getName()); - - private transient SessionFactory impl; - private transient HibernateService service; - private String uuid; - private String name; - - SessionFactoryStub(HibernateService service) { - this.service = service; - this.name = service.getJndiName(); - try { - uuid = (String) UUID_GENERATOR.generate(null, null); - } - catch (Exception e) { - throw new AssertionFailure("Could not generate UUID"); - } - - SessionFactoryRegistry.INSTANCE.addSessionFactory( - uuid, - name, - ConfigurationHelper.getBoolean( - AvailableSettings.SESSION_FACTORY_NAME_IS_JNDI, - service.getProperties(), - true - ), - this, - new JndiServiceImpl( service.getProperties() ) - ); - } - - @Override - public SessionFactoryOptions getSessionFactoryOptions() { - return impl.getSessionFactoryOptions(); - } - - @Override - public SessionBuilder withOptions() { - return getImpl().withOptions(); - } - - public Session openSession() throws HibernateException { - return getImpl().openSession(); - } - - public Session getCurrentSession() { - return getImpl().getCurrentSession(); - } - - private synchronized SessionFactory getImpl() { - if (impl==null) impl = service.buildSessionFactory(); - return impl; - } - - //readResolveObject - private Object readResolve() throws ObjectStreamException { - // look for the instance by uuid - Object result = SessionFactoryRegistry.INSTANCE.getSessionFactory( uuid ) ; - if ( result == null ) { - // in case we were deserialized in a different JVM, look for an instance with the same name - // (alternatively we could do an actual JNDI lookup here....) - result = SessionFactoryRegistry.INSTANCE.getNamedSessionFactory( name ); - if ( result == null ) { - throw new InvalidObjectException( "Could not find a SessionFactory [uuid=" + uuid + ",name=" + name + "]" ); - } - LOG.debug("Resolved stub SessionFactory by name"); - } - else { - LOG.debug("Resolved stub SessionFactory by UUID"); - } - return result; - } - - /** - * @see javax.naming.Referenceable#getReference() - */ - @Override - public Reference getReference() throws NamingException { - return new Reference( - SessionFactoryStub.class.getName(), - new StringRefAddr("uuid", uuid), - SessionFactoryRegistry.ObjectFactoryImpl.class.getName(), - null - ); - } - - public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException { - return getImpl().getClassMetadata(persistentClass); - } - - public ClassMetadata getClassMetadata(String entityName) - throws HibernateException { - return getImpl().getClassMetadata(entityName); - } - - public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException { - return getImpl().getCollectionMetadata(roleName); - } - - public Map getAllClassMetadata() throws HibernateException { - return getImpl().getAllClassMetadata(); - } - - public Map getAllCollectionMetadata() throws HibernateException { - return getImpl().getAllCollectionMetadata(); - } - - public void close() throws HibernateException { - } - - public boolean isClosed() { - return false; - } - - public Cache getCache() { - return getImpl().getCache(); - } - - public void evict(Class persistentClass, Serializable id) - throws HibernateException { - getImpl().evict(persistentClass, id); - } - - public void evict(Class persistentClass) throws HibernateException { - getImpl().evict(persistentClass); - } - - public void evictEntity(String entityName, Serializable id) - throws HibernateException { - getImpl().evictEntity(entityName, id); - } - - public void evictEntity(String entityName) throws HibernateException { - getImpl().evictEntity(entityName); - } - - public void evictCollection(String roleName, Serializable id) - throws HibernateException { - getImpl().evictCollection(roleName, id); - } - - public void evictCollection(String roleName) throws HibernateException { - getImpl().evictCollection(roleName); - } - - public void evictQueries() throws HibernateException { - getImpl().evictQueries(); - } - - public void evictQueries(String cacheRegion) throws HibernateException { - getImpl().evictQueries(cacheRegion); - } - - public Statistics getStatistics() { - return getImpl().getStatistics(); - } - - @Override - public StatelessSessionBuilder withStatelessOptions() { - return getImpl().withStatelessOptions(); - } - - public StatelessSession openStatelessSession() { - return getImpl().openStatelessSession(); - } - - public StatelessSession openStatelessSession(Connection conn) { - return getImpl().openStatelessSession(conn); - } - - public Set getDefinedFilterNames() { - return getImpl().getDefinedFilterNames(); - } - - public FilterDefinition getFilterDefinition(String filterName) throws HibernateException { - return getImpl().getFilterDefinition( filterName ); - } - - public boolean containsFetchProfileDefinition(String name) { - return getImpl().containsFetchProfileDefinition( name ); - } - - public TypeHelper getTypeHelper() { - return getImpl().getTypeHelper(); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsService.java b/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsService.java deleted file mode 100644 index 2895997b41..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsService.java +++ /dev/null @@ -1,367 +0,0 @@ -package org.hibernate.jmx; - -import javax.naming.InitialContext; -import javax.naming.NameNotFoundException; -import javax.naming.NamingException; -import javax.naming.Reference; - -import org.jboss.logging.Logger; - -import org.hibernate.SessionFactory; -import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.internal.SessionFactoryRegistry; -import org.hibernate.stat.CollectionStatistics; -import org.hibernate.stat.EntityStatistics; -import org.hibernate.stat.NaturalIdCacheStatistics; -import org.hibernate.stat.QueryStatistics; -import org.hibernate.stat.SecondLevelCacheStatistics; -import org.hibernate.stat.Statistics; -import org.hibernate.stat.internal.ConcurrentStatisticsImpl; - -/** - * JMX service for Hibernate statistics
    - *
    - * Register this MBean in your JMX server for a specific session factory - *
    - * //build the ObjectName you want
    - * Hashtable tb = new Hashtable();
    - * tb.put("type", "statistics");
    - * tb.put("sessionFactory", "myFinancialApp");
    - * ObjectName on = new ObjectName("hibernate", tb);
    - * StatisticsService stats = new StatisticsService();
    - * stats.setSessionFactory(sessionFactory);
    - * server.registerMBean(stats, on);
    - * 
    - * And call the MBean the way you want
    - *
    - * Register this MBean in your JMX server with no specific session factory - *
    - * //build the ObjectName you want
    - * Hashtable tb = new Hashtable();
    - * tb.put("type", "statistics");
    - * tb.put("sessionFactory", "myFinancialApp");
    - * ObjectName on = new ObjectName("hibernate", tb);
    - * StatisticsService stats = new StatisticsService();
    - * server.registerMBean(stats, on);
    - * 
    - * And call the MBean by providing the SessionFactoryJNDIName first. - * Then the session factory will be retrieved from JNDI and the statistics - * loaded. - * - * @author Emmanuel Bernard - * @deprecated See HHH-6190 for details - */ -@Deprecated -public class StatisticsService implements StatisticsServiceMBean { - - private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, StatisticsService.class.getName() ); - //TODO: We probably should have a StatisticsNotPublishedException, to make it clean - - SessionFactory sf; - String sfJNDIName; - Statistics stats = new ConcurrentStatisticsImpl(); - - /** - * @see StatisticsServiceMBean#setSessionFactoryJNDIName(java.lang.String) - */ - public void setSessionFactoryJNDIName(String sfJNDIName) { - this.sfJNDIName = sfJNDIName; - try { - final SessionFactory sessionFactory; - final Object jndiValue = new InitialContext().lookup( sfJNDIName ); - if ( jndiValue instanceof Reference ) { - final String uuid = (String) ( (Reference) jndiValue ).get( 0 ).getContent(); - sessionFactory = SessionFactoryRegistry.INSTANCE.getSessionFactory( uuid ); - } - else { - sessionFactory = (SessionFactory) jndiValue; - } - setSessionFactory( sessionFactory ); - } - catch (NameNotFoundException e) { - LOG.noSessionFactoryWithJndiName( sfJNDIName, e ); - setSessionFactory(null); - } - catch (NamingException e) { - LOG.unableToAccessSessionFactory( sfJNDIName, e ); - setSessionFactory(null); - } - catch (ClassCastException e) { - LOG.jndiNameDoesNotHandleSessionFactoryReference( sfJNDIName, e ); - setSessionFactory(null); - } - } - - /** - * Useful to init this MBean wo a JNDI session factory name - * - * @param sf session factory to register - */ - public void setSessionFactory(SessionFactory sf) { - this.sf = sf; - if (sf == null) { - stats = new ConcurrentStatisticsImpl(); - } - else { - stats = sf.getStatistics(); - } - - } - /** - * @see StatisticsServiceMBean#clear() - */ - public void clear() { - stats.clear(); - } - /** - * @see StatisticsServiceMBean#getEntityStatistics(java.lang.String) - */ - public EntityStatistics getEntityStatistics(String entityName) { - return stats.getEntityStatistics(entityName); - } - /** - * @see StatisticsServiceMBean#getCollectionStatistics(java.lang.String) - */ - public CollectionStatistics getCollectionStatistics(String role) { - return stats.getCollectionStatistics(role); - } - /** - * @see StatisticsServiceMBean#getSecondLevelCacheStatistics(java.lang.String) - */ - public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName) { - return stats.getSecondLevelCacheStatistics(regionName); - } - /** - * @see StatisticsServiceMBean#getQueryStatistics(java.lang.String) - */ - public QueryStatistics getQueryStatistics(String hql) { - return stats.getQueryStatistics(hql); - } - /** - * @see StatisticsServiceMBean#getEntityDeleteCount() - */ - public long getEntityDeleteCount() { - return stats.getEntityDeleteCount(); - } - /** - * @see StatisticsServiceMBean#getEntityInsertCount() - */ - public long getEntityInsertCount() { - return stats.getEntityInsertCount(); - } - /** - * @see StatisticsServiceMBean#getEntityLoadCount() - */ - public long getEntityLoadCount() { - return stats.getEntityLoadCount(); - } - /** - * @see StatisticsServiceMBean#getEntityFetchCount() - */ - public long getEntityFetchCount() { - return stats.getEntityFetchCount(); - } - /** - * @see StatisticsServiceMBean#getEntityUpdateCount() - */ - public long getEntityUpdateCount() { - return stats.getEntityUpdateCount(); - } - /** - * @see StatisticsServiceMBean#getQueryExecutionCount() - */ - public long getQueryExecutionCount() { - return stats.getQueryExecutionCount(); - } - public long getQueryCacheHitCount() { - return stats.getQueryCacheHitCount(); - } - public long getQueryExecutionMaxTime() { - return stats.getQueryExecutionMaxTime(); - } - public long getQueryCacheMissCount() { - return stats.getQueryCacheMissCount(); - } - public long getQueryCachePutCount() { - return stats.getQueryCachePutCount(); - } - - public long getUpdateTimestampsCacheHitCount() { - return stats.getUpdateTimestampsCacheHitCount(); - } - - public long getUpdateTimestampsCacheMissCount() { - return stats.getUpdateTimestampsCacheMissCount(); - } - - public long getUpdateTimestampsCachePutCount() { - return stats.getUpdateTimestampsCachePutCount(); - } - - /** - * @see StatisticsServiceMBean#getFlushCount() - */ - public long getFlushCount() { - return stats.getFlushCount(); - } - /** - * @see StatisticsServiceMBean#getConnectCount() - */ - public long getConnectCount() { - return stats.getConnectCount(); - } - /** - * @see StatisticsServiceMBean#getSecondLevelCacheHitCount() - */ - public long getSecondLevelCacheHitCount() { - return stats.getSecondLevelCacheHitCount(); - } - /** - * @see StatisticsServiceMBean#getSecondLevelCacheMissCount() - */ - public long getSecondLevelCacheMissCount() { - return stats.getSecondLevelCacheMissCount(); - } - /** - * @see StatisticsServiceMBean#getSecondLevelCachePutCount() - */ - public long getSecondLevelCachePutCount() { - return stats.getSecondLevelCachePutCount(); - } - - public NaturalIdCacheStatistics getNaturalIdCacheStatistics(String regionName) { - return stats.getNaturalIdCacheStatistics( regionName ); - } - - public long getNaturalIdCacheHitCount() { - return stats.getNaturalIdCacheHitCount(); - } - - public long getNaturalIdCacheMissCount() { - return stats.getNaturalIdCacheMissCount(); - } - - public long getNaturalIdCachePutCount() { - return stats.getNaturalIdCachePutCount(); - } - - @Override - public long getNaturalIdQueryExecutionCount() { - return stats.getNaturalIdQueryExecutionCount(); - } - - @Override - public long getNaturalIdQueryExecutionMaxTime() { - return stats.getNaturalIdQueryExecutionMaxTime(); - } - - @Override - public String getNaturalIdQueryExecutionMaxTimeRegion() { - return stats.getNaturalIdQueryExecutionMaxTimeRegion(); - } - - /** - * @see StatisticsServiceMBean#getSessionCloseCount() - */ - public long getSessionCloseCount() { - return stats.getSessionCloseCount(); - } - /** - * @see StatisticsServiceMBean#getSessionOpenCount() - */ - public long getSessionOpenCount() { - return stats.getSessionOpenCount(); - } - /** - * @see StatisticsServiceMBean#getCollectionLoadCount() - */ - public long getCollectionLoadCount() { - return stats.getCollectionLoadCount(); - } - /** - * @see StatisticsServiceMBean#getCollectionFetchCount() - */ - public long getCollectionFetchCount() { - return stats.getCollectionFetchCount(); - } - /** - * @see StatisticsServiceMBean#getCollectionUpdateCount() - */ - public long getCollectionUpdateCount() { - return stats.getCollectionUpdateCount(); - } - /** - * @see StatisticsServiceMBean#getCollectionRemoveCount() - */ - public long getCollectionRemoveCount() { - return stats.getCollectionRemoveCount(); - } - /** - * @see StatisticsServiceMBean#getCollectionRecreateCount() - */ - public long getCollectionRecreateCount() { - return stats.getCollectionRecreateCount(); - } - /** - * @see StatisticsServiceMBean#getStartTime() - */ - public long getStartTime() { - return stats.getStartTime(); - } - - /** - * @see StatisticsServiceMBean#isStatisticsEnabled() - */ - public boolean isStatisticsEnabled() { - return stats.isStatisticsEnabled(); - } - - /** - * @see StatisticsServiceMBean#setStatisticsEnabled(boolean) - */ - public void setStatisticsEnabled(boolean enable) { - stats.setStatisticsEnabled(enable); - } - - public void logSummary() { - stats.logSummary(); - } - - public String[] getCollectionRoleNames() { - return stats.getCollectionRoleNames(); - } - - public String[] getEntityNames() { - return stats.getEntityNames(); - } - - public String[] getQueries() { - return stats.getQueries(); - } - - public String[] getSecondLevelCacheRegionNames() { - return stats.getSecondLevelCacheRegionNames(); - } - - public long getSuccessfulTransactionCount() { - return stats.getSuccessfulTransactionCount(); - } - public long getTransactionCount() { - return stats.getTransactionCount(); - } - - public long getCloseStatementCount() { - return stats.getCloseStatementCount(); - } - public long getPrepareStatementCount() { - return stats.getPrepareStatementCount(); - } - - public long getOptimisticFailureCount() { - return stats.getOptimisticFailureCount(); - } - - public String getQueryExecutionMaxTimeQueryString() { - return stats.getQueryExecutionMaxTimeQueryString(); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsServiceMBean.java b/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsServiceMBean.java deleted file mode 100644 index 63d5514722..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsServiceMBean.java +++ /dev/null @@ -1,20 +0,0 @@ -//$Id: StatisticsServiceMBean.java 4332 2004-08-15 12:55:28Z oneovthafew $ -package org.hibernate.jmx; -import org.hibernate.stat.Statistics; - -/** - * MBean exposing Session Factory statistics - * - * @see org.hibernate.stat.Statistics - * @author Emmanuel Bernard - * @deprecated See HHH-6190 for details - */ -@Deprecated -public interface StatisticsServiceMBean extends Statistics { - /** - * Publish the statistics of a session factory bound to - * the default JNDI context - * @param sfJNDIName session factory jndi name - */ - public abstract void setSessionFactoryJNDIName(String sfJNDIName); -} \ No newline at end of file diff --git a/hibernate-core/src/main/java/org/hibernate/transaction/TransactionManagerLookup.java b/hibernate-core/src/main/java/org/hibernate/transaction/TransactionManagerLookup.java deleted file mode 100644 index 2656ae938f..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/transaction/TransactionManagerLookup.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2008, 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.transaction; -import java.util.Properties; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; - -import org.hibernate.HibernateException; - -/** - * Contract for locating the JTA {@link TransactionManager} on given platform. - *

    - * NOTE: this contract has expanded over time, and basically is a platform - * abstraction contract for JTA-related information. - * - * @author Gavin King - */ -public interface TransactionManagerLookup { - - /** - * Obtain the JTA {@link TransactionManager}. - * - * @param props The configuration properties. - * @return The JTA {@link TransactionManager}. - * - * @throws HibernateException Indicates problem locating {@link TransactionManager}. - */ - public TransactionManager getTransactionManager(Properties props) throws HibernateException; - - /** - * Return the JNDI namespace of the JTA - * {@link javax.transaction.UserTransaction} for this platform or null; - * optional operation. - * - * @return The JNDI namespace where we can locate the - * {@link javax.transaction.UserTransaction} for this platform. - */ - public String getUserTransactionName(); - - /** - * Determine an identifier for the given transaction appropriate for use in caching/lookup usages. - *

    - * Generally speaking the transaction itself will be returned here. This method was added specifically - * for use in WebSphere and other unfriendly JEE containers (although WebSphere is still the only known - * such brain-dead, sales-driven impl). - * - * @param transaction The transaction to be identified. - * @return An appropropriate identifier - */ - public Object getTransactionIdentifier(Transaction transaction); -} - diff --git a/hibernate-core/src/main/java/org/hibernate/transaction/package.html b/hibernate-core/src/main/java/org/hibernate/transaction/package.html deleted file mode 100755 index 895501cfc1..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/transaction/package.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - -

    - This package abstracts the underlying transaction mechanism - (JTA or JDBC) and provides strategies for obtaining application - server TransactionManagers. -

    - - diff --git a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java index 957392a496..f166212290 100644 --- a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java @@ -29,10 +29,11 @@ import java.util.HashMap; import java.util.Map; import java.util.Properties; -import org.junit.Before; -import org.junit.Test; - import org.hibernate.HibernateException; +import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl; +import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; +import org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder; +import org.hibernate.boot.registry.selector.spi.StrategySelectionException; import org.hibernate.cfg.Environment; import org.hibernate.dialect.DB2400Dialect; import org.hibernate.dialect.DB2Dialect; @@ -55,12 +56,14 @@ import org.hibernate.dialect.SQLServerDialect; import org.hibernate.dialect.SybaseASE15Dialect; import org.hibernate.dialect.SybaseAnywhereDialect; import org.hibernate.dialect.TestingDialects; -import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl; -import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl; import org.hibernate.engine.jdbc.dialect.internal.DialectResolverSet; import org.hibernate.engine.jdbc.dialect.internal.StandardDialectResolver; import org.hibernate.engine.jdbc.dialect.spi.DialectResolver; + +import org.junit.Before; +import org.junit.Test; + import org.hibernate.testing.junit4.BaseUnitTestCase; import static org.junit.Assert.assertEquals; @@ -76,10 +79,23 @@ public class DialectFactoryTest extends BaseUnitTestCase { @Before public void setUp() { dialectFactory = new DialectFactoryImpl(); - dialectFactory.setClassLoaderService( new ClassLoaderServiceImpl( getClass().getClassLoader() ) ); + dialectFactory.setStrategySelector( + new StrategySelectorBuilder().buildSelector( new ClassLoaderServiceImpl( getClass().getClassLoader() ) ) + ); dialectFactory.setDialectResolver( new StandardDialectResolver() ); } + @Test + public void testExplicitShortNameUse() { + final Map configValues = new HashMap(); + + configValues.put( Environment.DIALECT, "H2" ); + assertEquals( H2Dialect.class, dialectFactory.buildDialect( configValues, null ).getClass() ); + + configValues.put( Environment.DIALECT, "Oracle10g" ); + assertEquals( Oracle10gDialect.class, dialectFactory.buildDialect( configValues, null ).getClass() ); + } + @Test public void testExplicitlySuppliedDialectClassName() { final Map configValues = new HashMap(); @@ -93,7 +109,7 @@ public class DialectFactoryTest extends BaseUnitTestCase { fail(); } catch ( HibernateException e ) { - assertEquals( "unexpected exception type", ClassLoadingException.class, e.getCause().getClass() ); + assertEquals( "unexpected exception type", StrategySelectionException.class, e.getClass() ); } configValues.put( Environment.DIALECT, "java.lang.Object" ); diff --git a/hibernate-core/src/test/java/org/hibernate/jmx/Entity.hbm.xml b/hibernate-core/src/test/java/org/hibernate/jmx/Entity.hbm.xml deleted file mode 100644 index a4502b40d7..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/jmx/Entity.hbm.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/hibernate-core/src/test/java/org/hibernate/jmx/Entity.java b/hibernate-core/src/test/java/org/hibernate/jmx/Entity.java deleted file mode 100644 index 035a2dddb7..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/jmx/Entity.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.hibernate.jmx; - - -/** - * {@inheritDoc} - * - * @author Steve Ebersole - */ -public class Entity { - private Long id; - private String name; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/jmx/TrivialTest.java b/hibernate-core/src/test/java/org/hibernate/jmx/TrivialTest.java deleted file mode 100644 index 5ff5e054f1..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/jmx/TrivialTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, 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 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 - * 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.jmx; - -import org.junit.Test; - -import org.hibernate.testing.junit4.BaseUnitTestCase; - -/** - * @author Steve Ebersole - */ -public class TrivialTest extends BaseUnitTestCase { - @Test - public void testService() throws Exception { - HibernateService hs = new HibernateService(); - hs.setJndiName( "SessionFactory" ); - hs.setMapResources( "org/hibernate/jmx/Entity.hbm.xml" ); - hs.setShowSqlEnabled( "true" ); - hs.start(); - hs.stop(); - hs.setProperty( "foo", "bar" ); - hs.start(); - hs.stop(); - try { - hs.setMapResources( "non-existent" ); - hs.start(); - } - catch( Throwable t ) { - // expected behavior - } - finally { - hs.stop(); - } - } -} diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTransactionManagerLookup.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTransactionManagerLookup.java deleted file mode 100644 index 6a8ed79294..0000000000 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTransactionManagerLookup.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2007, Red Hat, Inc. and/or it's affiliates 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, Inc. and/or it's affiliates. - * - * 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.test.cache.infinispan.functional.cluster; - -import java.util.Properties; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; - -import org.hibernate.HibernateException; -import org.hibernate.transaction.TransactionManagerLookup; - -/** - * SimpleJtaTransactionManagerLookupImpl subclass that finds a different DualNodeTransactionManager - * based on the value of property {@link DualNodeTestUtil#NODE_ID_PROP}. - * - * @author Brian Stansberry - */ -public class DualNodeTransactionManagerLookup implements TransactionManagerLookup { - - public TransactionManager getTransactionManager(Properties props) throws HibernateException { - String nodeId = props.getProperty(DualNodeTestCase.NODE_ID_PROP); - if (nodeId == null) - throw new HibernateException(DualNodeTestCase.NODE_ID_PROP + " not configured"); - return DualNodeJtaTransactionManagerImpl.getInstance(nodeId); - } - - public String getUserTransactionName() { - throw new UnsupportedOperationException("jndi currently not implemented for these tests"); - } - - public Object getTransactionIdentifier(Transaction transaction) { - return transaction; - } -} diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JBossStandaloneJtaExampleTest.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JBossStandaloneJtaExampleTest.java index 73e2388a78..92b3ec667f 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JBossStandaloneJtaExampleTest.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JBossStandaloneJtaExampleTest.java @@ -61,6 +61,9 @@ import org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJta import org.hibernate.stat.Statistics; import org.hibernate.test.cache.infinispan.functional.Item; import org.hibernate.testing.ServiceRegistryBuilder; +import org.hibernate.testing.jta.JtaAwareConnectionProviderImpl; +import org.hibernate.testing.jta.TestingJtaBootstrap; +import org.hibernate.testing.jta.TestingJtaPlatformImpl; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -87,10 +90,9 @@ public class JBossStandaloneJtaExampleTest { jndiServer = startJndiServer(); ctx = createJndiContext(); // Inject configuration to initialise transaction manager from config classloader - lookup.init(new org.infinispan.config.Configuration()); + lookup.init( new org.infinispan.config.Configuration() ); bindTransactionManager(); bindUserTransaction(); - bindDataSource(); } @After @@ -177,51 +179,20 @@ public class JBossStandaloneJtaExampleTest { } - public static class ExtendedXADataSource extends StandardXADataSource { // XAPOOL - @Override - public Connection getConnection() throws SQLException { - - if (getTransactionManager() == null) { // although already set before, it results null again after retrieving the datasource by jndi - TransactionManager tm; // this is because the TransactionManager information is not serialized. - try { - tm = lookup.getTransactionManager(); - } catch (Exception e) { - throw new SQLException(e); - } - setTransactionManager(tm); // resets the TransactionManager on the datasource retrieved by jndi, - // this makes the datasource JTA-aware - } - - // According to Enhydra documentation, here we must return the connection of our XAConnection - // see http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/xapool/xapool/examples/xapooldatasource/DatabaseHelper.java?sortby=rev - return super.getXAConnection().getConnection(); - } - - @Override - public T unwrap(Class iface) throws SQLException { - return null; // JDK6 stuff - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return false; // JDK6 stuff - } - } - private Main startJndiServer() throws Exception { // Create an in-memory jndi NamingServer namingServer = new NamingServer(); NamingContext.setLocal(namingServer); Main namingMain = new Main(); namingMain.setInstallGlobalService(true); - namingMain.setPort(-1); + namingMain.setPort( -1 ); namingMain.start(); return namingMain; } private Context createJndiContext() throws Exception { Properties props = new Properties(); - props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); + props.put( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" ); props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); return new InitialContext(props); } @@ -233,14 +204,7 @@ public class JBossStandaloneJtaExampleTest { private void bindUserTransaction() throws Exception { // also the UserTransaction must be registered on jndi: org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory#getUserTransaction() requires this - bind("UserTransaction", lookup.getUserTransaction(), lookup.getUserTransaction().getClass(), ctx); - } - - private void bindDataSource() throws Exception { - ExtendedXADataSource xads = new ExtendedXADataSource(); - xads.setDriverName("org.h2.Driver"); - xads.setUrl("jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE"); - ctx.bind("java:/MyDatasource", xads); + bind( "UserTransaction", lookup.getUserTransaction(), lookup.getUserTransaction().getClass(), ctx ); } /** @@ -282,12 +246,11 @@ public class JBossStandaloneJtaExampleTest { private SessionFactory buildSessionFactory() { // Extra options located in src/test/resources/hibernate.properties Configuration cfg = new Configuration(); - cfg.setProperty(Environment.DIALECT, "org.hibernate.dialect.HSQLDialect"); - cfg.setProperty(Environment.HBM2DDL_AUTO, "create-drop"); - cfg.setProperty(Environment.DATASOURCE, "java:/MyDatasource"); + cfg.setProperty( Environment.DIALECT, "HSQL" ); + cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); + cfg.setProperty( Environment.CONNECTION_PROVIDER, JtaAwareConnectionProviderImpl.class.getName() ); cfg.setProperty(Environment.JNDI_CLASS, "org.jnp.interfaces.NamingContextFactory"); - cfg.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, "org.hibernate.transaction.JBossTransactionManagerLookup"); - cfg.setProperty(Environment.TRANSACTION_STRATEGY, "org.hibernate.transaction.JTATransactionFactory"); + cfg.setProperty(Environment.TRANSACTION_STRATEGY, "jta"); cfg.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "jta"); cfg.setProperty(Environment.RELEASE_CONNECTIONS, "auto"); cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true"); diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeTransactionManagerLookup.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeTransactionManagerLookup.java deleted file mode 100755 index bf2f29625a..0000000000 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeTransactionManagerLookup.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2007, Red Hat, Inc. and/or it's affiliates 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, Inc. and/or it's affiliates. - * - * 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.test.cache.infinispan.util; - -import java.util.Properties; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; - -import org.infinispan.transaction.tm.BatchModeTransactionManager; - -import org.hibernate.HibernateException; -import org.hibernate.transaction.TransactionManagerLookup; - -/** - * Uses the JBoss Cache BatchModeTransactionManager. Should not be used in - * any tests that simulate usage of database connections. - * - * @author Brian Stansberry - */ -public class BatchModeTransactionManagerLookup - implements TransactionManagerLookup { - - public TransactionManager getTransactionManager(Properties props) throws HibernateException { - try { - return BatchModeTransactionManager.getInstance(); - } - catch (Exception e) { - throw new HibernateException("Failed getting BatchModeTransactionManager", e); - } - } - - public String getUserTransactionName() { - throw new UnsupportedOperationException(); - } - - public Object getTransactionIdentifier(Transaction transaction) { - return transaction; - } - -} From 759620cecb4b36871d2b1b1824cad6b9069cf373 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 29 Aug 2012 11:16:17 -0500 Subject: [PATCH 10/38] HHH-6823 - Short-name config values --- .../internal/StrategySelectorBuilder.java | 92 ++++++++++--------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java index b2480a90ac..cf35ce47e8 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java @@ -151,48 +151,56 @@ public class StrategySelectorBuilder { } private void addDialects(StrategySelectorImpl strategySelector) { - strategySelector.registerStrategyImplementor( Dialect.class, "Cache71", Cache71Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "CUBRID", CUBRIDDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "DB2", DB2Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "DB2-390", DB2390Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "DB2-400", DB2400Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Derby10.5", DerbyTenFiveDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Derby10.6", DerbyTenSixDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Derby10.7", DerbyTenSevenDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Firebird", FirebirdDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "FrontBase", FrontBaseDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "H2", H2Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "HSQL", HSQLDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Informix", InformixDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Ingres", IngresDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Ingres9", Ingres9Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Ingres10", Ingres10Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Interbase", InterbaseDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "JDataStore", JDataStoreDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Mckoi", MckoiDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "MimerSQL", MimerSQLDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "MySQL5", MySQL5Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "MySQL5-InnoDB", MySQL5InnoDBDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "MySQL", MySQL5Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "MySQL-InnoDB", MySQL5InnoDBDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Oracle8i", Oracle8iDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Oracle9i", Oracle9iDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Oracle10g", Oracle10gDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Pointbase", PointbaseDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "PostgresPlus", PostgresPlusDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "PostgreSQL81", PostgreSQL81Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "PostgreSQL82", PostgreSQL82Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Progress", ProgressDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "SAP", SAPDBDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "SQLServer", SQLServerDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "SQLServer2005", SQLServer2005Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "SQLServer2008", SQLServer2008Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Sybase11", Sybase11Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "SybaseAnywhere", SybaseAnywhereDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "SybaseASE15", SybaseASE15Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "SybaseASE157", SybaseASE157Dialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "Teradata", TeradataDialect.class ); - strategySelector.registerStrategyImplementor( Dialect.class, "TimesTen", TimesTenDialect.class ); + addDialect( strategySelector, Cache71Dialect.class ); + addDialect( strategySelector, CUBRIDDialect.class ); + addDialect( strategySelector, DB2Dialect.class ); + addDialect( strategySelector, DB2390Dialect.class ); + addDialect( strategySelector, DB2400Dialect.class ); + addDialect( strategySelector, DerbyTenFiveDialect.class ); + addDialect( strategySelector, DerbyTenSixDialect.class ); + addDialect( strategySelector, DerbyTenSevenDialect.class ); + addDialect( strategySelector, FirebirdDialect.class ); + addDialect( strategySelector, FrontBaseDialect.class ); + addDialect( strategySelector, H2Dialect.class ); + addDialect( strategySelector, HSQLDialect.class ); + addDialect( strategySelector, InformixDialect.class ); + addDialect( strategySelector, IngresDialect.class ); + addDialect( strategySelector, Ingres9Dialect.class ); + addDialect( strategySelector, Ingres10Dialect.class ); + addDialect( strategySelector, InterbaseDialect.class ); + addDialect( strategySelector, JDataStoreDialect.class ); + addDialect( strategySelector, MckoiDialect.class ); + addDialect( strategySelector, MimerSQLDialect.class ); + addDialect( strategySelector, MySQL5Dialect.class ); + addDialect( strategySelector, MySQL5InnoDBDialect.class ); + addDialect( strategySelector, MySQL5Dialect.class ); + addDialect( strategySelector, MySQL5InnoDBDialect.class ); + addDialect( strategySelector, Oracle8iDialect.class ); + addDialect( strategySelector, Oracle9iDialect.class ); + addDialect( strategySelector, Oracle10gDialect.class ); + addDialect( strategySelector, PointbaseDialect.class ); + addDialect( strategySelector, PostgresPlusDialect.class ); + addDialect( strategySelector, PostgreSQL81Dialect.class ); + addDialect( strategySelector, PostgreSQL82Dialect.class ); + addDialect( strategySelector, ProgressDialect.class ); + addDialect( strategySelector, SAPDBDialect.class ); + addDialect( strategySelector, SQLServerDialect.class ); + addDialect( strategySelector, SQLServer2005Dialect.class ); + addDialect( strategySelector, SQLServer2008Dialect.class ); + addDialect( strategySelector, Sybase11Dialect.class ); + addDialect( strategySelector, SybaseAnywhereDialect.class ); + addDialect( strategySelector, SybaseASE15Dialect.class ); + addDialect( strategySelector, SybaseASE157Dialect.class ); + addDialect( strategySelector, TeradataDialect.class ); + addDialect( strategySelector, TimesTenDialect.class ); + } + + private void addDialect(StrategySelectorImpl strategySelector, Class dialectClass) { + String simpleName = dialectClass.getSimpleName(); + if ( simpleName.endsWith( "Dialect" ) ) { + simpleName = simpleName.substring( 0, simpleName.length() - "Dialect".length() ); + } + strategySelector.registerStrategyImplementor( Dialect.class, simpleName, dialectClass ); } private void addJtaPlatforms(StrategySelectorImpl strategySelector) { From d4eade81991aed73e5768eff140b4349e479dcee Mon Sep 17 00:00:00 2001 From: brmeyer Date: Wed, 29 Aug 2012 17:58:11 -0400 Subject: [PATCH 11/38] HHH-7560 ehcache unit test intermittently failing (UnknownServiceException) --- .../test/cache/HibernateCacheTest.java | 76 +++++++------------ 1 file changed, 27 insertions(+), 49 deletions(-) diff --git a/hibernate-ehcache/src/test/java/org/hibernate/test/cache/HibernateCacheTest.java b/hibernate-ehcache/src/test/java/org/hibernate/test/cache/HibernateCacheTest.java index e118a6c163..a8244b3ef1 100644 --- a/hibernate-ehcache/src/test/java/org/hibernate/test/cache/HibernateCacheTest.java +++ b/hibernate-ehcache/src/test/java/org/hibernate/test/cache/HibernateCacheTest.java @@ -1,17 +1,15 @@ package org.hibernate.test.cache; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + import java.util.Date; import java.util.List; import java.util.Map; import org.hamcrest.CoreMatchers; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.hibernate.HibernateException; import org.hibernate.Session; -import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cache.ehcache.internal.strategy.ItemValueExtractor; import org.hibernate.cache.spi.access.SoftLock; @@ -25,49 +23,31 @@ import org.hibernate.test.domain.Item; import org.hibernate.test.domain.Person; import org.hibernate.test.domain.PhoneNumber; import org.hibernate.test.domain.VersionedItem; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.junit.Test; /** * @author Chris Dennis + * @author Brett Meyer */ -public class HibernateCacheTest { +public class HibernateCacheTest extends BaseCoreFunctionalTestCase { - private static SessionFactory sessionFactory; - private static Configuration config; private static final String REGION_PREFIX = "hibernate.test."; - public synchronized static SessionFactory getSessionFactory() { - if ( sessionFactory == null ) { - try { - sessionFactory = config.buildSessionFactory(); - } - catch ( HibernateException ex ) { - System.err.println( "Initial SessionFactory creation failed." + ex ); - throw new ExceptionInInitializerError( ex ); - } - } - return sessionFactory; - } - - @BeforeClass - public static void setUp() { + @Override + protected void configure(Configuration config) { System.setProperty( "derby.system.home", "target/derby" ); - config = new Configuration().configure( "/hibernate-config/hibernate.cfg.xml" ); - config.setProperty( "hibernate.hbm2ddl.auto", "create" ); - getSessionFactory().getStatistics().setStatisticsEnabled( true ); + config.configure( "hibernate-config/hibernate.cfg.xml" ); } - - @AfterClass - public static void tearDown() { - getSessionFactory().close(); + + @Override + protected void afterSessionFactoryBuilt() { + sessionFactory().getStatistics().setStatisticsEnabled( true ); } @Test public void testQueryCacheInvalidation() throws Exception { - Session s = getSessionFactory().openSession(); + Session s = sessionFactory().openSession(); Transaction t = s.beginTransaction(); Item i = new Item(); i.setName( "widget" ); @@ -76,7 +56,7 @@ public class HibernateCacheTest { t.commit(); s.close(); - SecondLevelCacheStatistics slcs = s.getSessionFactory() + SecondLevelCacheStatistics slcs = sessionFactory() .getStatistics() .getSecondLevelCacheStatistics( REGION_PREFIX + Item.class.getName() ); @@ -84,7 +64,7 @@ public class HibernateCacheTest { assertThat( slcs.getElementCountInMemory(), equalTo( 1L ) ); assertThat( slcs.getEntries().size(), equalTo( 1 ) ); - s = getSessionFactory().openSession(); + s = sessionFactory().openSession(); t = s.beginTransaction(); i = (Item) s.get( Item.class, i.getId() ); @@ -110,7 +90,7 @@ public class HibernateCacheTest { assertThat( (String) map.get( "name" ), equalTo( "widget" ) ); // cleanup - s = getSessionFactory().openSession(); + s = sessionFactory().openSession(); t = s.beginTransaction(); s.delete( i ); t.commit(); @@ -119,8 +99,8 @@ public class HibernateCacheTest { @Test public void testEmptySecondLevelCacheEntry() throws Exception { - getSessionFactory().evictEntity( Item.class.getName() ); - Statistics stats = getSessionFactory().getStatistics(); + sessionFactory().evictEntity( Item.class.getName() ); + Statistics stats = sessionFactory().getStatistics(); stats.clear(); SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics( REGION_PREFIX + Item.class.getName() ); Map cacheEntries = statistics.getEntries(); @@ -129,7 +109,7 @@ public class HibernateCacheTest { @Test public void testStaleWritesLeaveCacheConsistent() { - Session s = getSessionFactory().openSession(); + Session s = sessionFactory().openSession(); Transaction txn = s.beginTransaction(); VersionedItem item = new VersionedItem(); item.setName( "steve" ); @@ -144,7 +124,7 @@ public class HibernateCacheTest { item.setVersion( item.getVersion() - 1 ); try { - s = getSessionFactory().openSession(); + s = sessionFactory().openSession(); txn = s.beginTransaction(); s.update( item ); txn.commit(); @@ -172,7 +152,7 @@ public class HibernateCacheTest { } // check the version value in the cache... - SecondLevelCacheStatistics slcs = getSessionFactory().getStatistics() + SecondLevelCacheStatistics slcs = sessionFactory().getStatistics() .getSecondLevelCacheStatistics( REGION_PREFIX + VersionedItem.class.getName() ); assertThat( slcs, CoreMatchers.notNullValue() ); final Map entries = slcs.getEntries(); @@ -189,7 +169,7 @@ public class HibernateCacheTest { // cleanup - s = getSessionFactory().openSession(); + s = sessionFactory().openSession(); txn = s.beginTransaction(); item = (VersionedItem) s.load( VersionedItem.class, item.getId() ); s.delete( item ); @@ -200,8 +180,8 @@ public class HibernateCacheTest { @Test public void testGeneralUsage() { - EventManager mgr = new EventManager( getSessionFactory() ); - Statistics stats = getSessionFactory().getStatistics(); + EventManager mgr = new EventManager( sessionFactory() ); + Statistics stats = sessionFactory().getStatistics(); // create 3 persons Steve, Orion, Tim Person stevePerson = new Person(); @@ -247,8 +227,6 @@ public class HibernateCacheTest { mgr.listEmailsOfEvent( event.getId() ); } - getSessionFactory().close(); - QueryStatistics queryStats = stats.getQueryStatistics( "from Event" ); assertThat( "Cache Miss Count", queryStats.getCacheMissCount(), equalTo( 1L ) ); assertThat( "Cache Hit Count", queryStats.getCacheHitCount(), equalTo( 0L ) ); From 3e2be6a009e6783c30ad6483ff378770d5105f4b Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Thu, 30 Aug 2012 10:45:35 -0500 Subject: [PATCH 12/38] HHH-7557 - Map entries get deleted --- .../collection/internal/PersistentMap.java | 31 +++- .../collection/map/hhh7557/EntityMapTest.java | 105 ++++++++++++ .../collection/map/hhh7557/MapHolder.java | 80 +++++++++ .../test/collection/map/hhh7557/MapKey.java | 154 ++++++++++++++++++ .../test/collection/map/hhh7557/MapValue.java | 123 ++++++++++++++ 5 files changed, 488 insertions(+), 5 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/EntityMapTest.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapHolder.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapKey.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapValue.java diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentMap.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentMap.java index d3912a4928..02ea3a6f4e 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentMap.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentMap.java @@ -271,14 +271,35 @@ public class PersistentMap extends AbstractPersistentCollection implements Map { return map.toString(); } - public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner) - throws HibernateException, SQLException { - Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ); - Object index = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ); - if ( element!=null ) map.put(index, element); + private transient List loadingEntries; + + public Object readFrom( + ResultSet rs, + CollectionPersister persister, + CollectionAliases descriptor, + Object owner) throws HibernateException, SQLException { + final Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ); + if ( element != null ) { + final Object index = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ); + if ( loadingEntries == null ) { + loadingEntries = new ArrayList(); + } + loadingEntries.add( new Object[] { index, element } ); + } return element; } + @Override + @SuppressWarnings("unchecked") + public boolean endRead() { + if ( loadingEntries != null ) { + for ( Object[] entry : loadingEntries ) { + map.put( entry[0], entry[1] ); + } + } + return super.endRead(); + } + public Iterator entries(CollectionPersister persister) { return map.entrySet().iterator(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/EntityMapTest.java b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/EntityMapTest.java new file mode 100644 index 0000000000..5dfa28a905 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/EntityMapTest.java @@ -0,0 +1,105 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.collection.map.hhh7557; + +import java.util.HashMap; +import java.util.List; + +import org.hibernate.Session; + +import org.junit.Assert; +import org.junit.Test; + +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; + +/** + * @author Elizabeth Chatman + * @author Steve Ebersole + */ +public class EntityMapTest extends BaseCoreFunctionalTestCase { + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] {MapValue.class, MapKey.class, MapHolder.class}; + } + + @Test + public void testInsertIntoMap() throws Exception { + { + // Session 1: Insert 3 values into the map + Session session = openSession(); + session.beginTransaction(); + MapHolder mapHolder = new MapHolder(); + mapHolder.setMap( new HashMap() ); + addMapEntry( session, mapHolder, "A", "1" ); + addMapEntry( session, mapHolder, "B", "2" ); + addMapEntry( session, mapHolder, "C", "3" ); + session.save( mapHolder ); + // Verify there are 3 entries in the map + Assert.assertEquals( 3, mapHolder.getMap().size() ); + session.getTransaction().commit(); + session.close(); + } + + { + // Session 2: Add a 4th value to the map + Session session = openSession(); + session.beginTransaction(); + MapHolder mapHolder = getMapHolder( session ); + System.out.println( "Got MapHolder; checking map size -----" ); + Assert.assertEquals( 3, mapHolder.getMap().size() ); + System.out.println( "Got MapHolder; checked map size -----" ); + addMapEntry( session, mapHolder, "D", "4" ); + // Verify there are 4 entries in the map + Assert.assertEquals( 4, mapHolder.getMap().size() ); + session.getTransaction().commit(); + session.close(); + } + + { + // Session 3: Count the entries in the map + Session session = openSession(); + session.beginTransaction(); + MapHolder mapHolder = getMapHolder( session ); + // Fails here (expected:<4> but was:<1>) + Assert.assertEquals( 4, mapHolder.getMap().size() ); + session.getTransaction().commit(); + session.close(); + } + } + + private void addMapEntry(Session session, MapHolder mapHolder, String key, String value) { + System.out.println( "Inserting (" + key + "," + value + ") into map" ); + MapValue entityValue = new MapValue( value ); + session.save( entityValue ); + MapKey entityKey = new MapKey( key, entityValue ); + session.save( entityKey ); + mapHolder.getMap().put( entityKey, entityValue ); + } + + private MapHolder getMapHolder(Session session) { + List mapHolders = session.createQuery( "select distinct mh from MapHolder mh" ).list(); + Assert.assertEquals( 1, mapHolders.size() ); + return (MapHolder) mapHolders.get( 0 ); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapHolder.java b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapHolder.java new file mode 100644 index 0000000000..6055c7f2e9 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapHolder.java @@ -0,0 +1,80 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.collection.map.hhh7557; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.MapKeyJoinColumn; +import javax.persistence.Table; +import java.util.Map; + +/** + * @author Elizabeth Chatman + * @author Steve Ebersole + */ +@Entity +@Table(name = "map_holder") +public class MapHolder { + private Long id; + private Map map; + + @Id + @GeneratedValue + @Column(name = "id", unique = true, nullable = false) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @ManyToMany + @JoinTable( + name = "map_key_map_value", + joinColumns = @JoinColumn(name = "map_holder_id", nullable = false), + inverseJoinColumns = @JoinColumn(name = "map_value_id", nullable = false) + ) + @MapKeyJoinColumn(name = "map_key_id", nullable = false) + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append( "MapHolder [id=" ).append( id ).append( "]" ); + return builder.toString(); + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapKey.java b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapKey.java new file mode 100644 index 0000000000..3bba1a0ae1 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapKey.java @@ -0,0 +1,154 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.collection.map.hhh7557; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; + +import org.jboss.logging.Logger; + +/** + * @author Elizabeth Chatman + * @author Steve Ebersole + */ +@Entity +@Table(name = "map_key", uniqueConstraints = { + @UniqueConstraint(columnNames = {"name", "default_map_value_id"}) +}) +public class MapKey { + private static final Logger log = Logger.getLogger( MapKey.class ); + + private Long id; + private String name; + private MapValue defaultValue; + + public MapKey() { + } + + public MapKey(String name, MapValue defaultValue) { + this.name = name; + this.defaultValue = defaultValue; + } + + @Id + @GeneratedValue + @Column(name = "id", unique = true, nullable = false) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @Column(name = "name", nullable = false) + public String getName() { + return name; + } + + public void setName(String name) { + log.tracef( "Setting name : %s", name ); + this.name = name; + } + + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumn(name = "default_map_value_id", nullable = false) + public MapValue getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(MapValue defaultValue) { + log.tracef( "Setting defaultValue : %s", defaultValue ); + this.defaultValue = defaultValue; + } + + private int previousHashCode = -1; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getDefaultValue() == null) ? 0 : getDefaultValue().hashCode()); + result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); + log.tracef( + "Calculated hashcode [%s] = %s (previous=%s, changed?=%s)", + this, + result, + previousHashCode, + !(previousHashCode == -1 || previousHashCode == result) + ); + previousHashCode = result; + return result; + } + + @Override + public boolean equals(Object obj) { + log.tracef( "Checking equality : %s -> %s", this, obj ); + if ( this == obj ) { + return true; + } + if ( obj == null ) { + return false; + } + if ( !(obj instanceof MapKey) ) { + return false; + } + MapKey other = (MapKey) obj; + if ( getDefaultValue() == null ) { + if ( other.getDefaultValue() != null ) { + return false; + } + } + else if ( !getDefaultValue().equals( other.getDefaultValue() ) ) { + return false; + } + if ( getName() == null ) { + if ( other.getName() != null ) { + return false; + } + } + else if ( !getName().equals( other.getName() ) ) { + return false; + } + return true; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append( "MapKey [id=" ).append( getId() ) + .append( ", name=" ).append( getName() ) + .append( ", defaultValue=" ).append( getDefaultValue() ) + .append( "]" ); + return builder.toString(); + } + +} \ No newline at end of file diff --git a/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapValue.java b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapValue.java new file mode 100644 index 0000000000..0a1c1473d7 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapValue.java @@ -0,0 +1,123 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.collection.map.hhh7557; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.jboss.logging.Logger; + +/** + * @author Elizabeth Chatman + * @author Steve Ebersole + */ +@Entity +@Table(name = "map_value") +public class MapValue { + private static final Logger log = Logger.getLogger( MapValue.class ); + + private Long id; + private String name; + + public MapValue() { + } + + public MapValue(String name) { + this.name = name; + } + + @Id + @GeneratedValue + @Column(name = "id", unique = true, nullable = false) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @Column(name = "name", unique = true, nullable = false) + public String getName() { + return name; + } + + public void setName(String name) { + log.tracef( "Setting name : %s", name ); + this.name = name; + } + + int previousHashCode = -1; + + @Override + public int hashCode() { + + final int prime = 31; + int result = 1; + result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); + log.tracef( + "Calculated hashcode [%s] = %s (previous=%s, changed?=%s)", + this, + result, + previousHashCode, + !(previousHashCode == -1 || previousHashCode == result) + ); + previousHashCode = result; + return result; + } + + @Override + public boolean equals(Object obj) { + log.tracef( "Checking equality : %s -> %s", this, obj ); + if ( this == obj ) { + return true; + } + if ( obj == null ) { + return false; + } + if ( !(obj instanceof MapValue) ) { + return false; + } + MapValue other = (MapValue) obj; + if ( getName() == null ) { + if ( other.getName() != null ) { + return false; + } + } + else if ( !getName().equals( other.getName() ) ) { + return false; + } + return true; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append( "MapValue [id=" ).append( getId() ).append( ", name=" ).append( getName() ).append( "]" ); + return builder.toString(); + } +} From 8e30a2b86d692ce135d4947edf2358deb69e1e38 Mon Sep 17 00:00:00 2001 From: Didier Villevalois Date: Thu, 1 Mar 2012 15:44:38 +0100 Subject: [PATCH 13/38] HHH-7134 - Detection of wrong circularity when two tables with same name in different schemas Fixes FKSecondPass processing to take catalog and schema in accounts. Corresponding test class is org.hibernate.test.cfg.WrongCircularityDetectionTest. --- .../java/org/hibernate/cfg/Configuration.java | 8 +- .../cfg/WrongCircularityDetectionTest.java | 74 +++++++++++++++++++ 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/cfg/WrongCircularityDetectionTest.java diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java index 306b9917b3..5a3a66d274 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java @@ -1425,7 +1425,7 @@ public class Configuration implements Serializable { if ( sp.isInPrimaryKey() ) { String referenceEntityName = sp.getReferencedEntityName(); PersistentClass classMapping = getClassMapping( referenceEntityName ); - String dependentTable = classMapping.getTable().getQuotedName(); + String dependentTable = quotedTableName(classMapping.getTable()); if ( !isADependencyOf.containsKey( dependentTable ) ) { isADependencyOf.put( dependentTable, new HashSet() ); } @@ -1495,7 +1495,7 @@ public class Configuration implements Serializable { } for ( FkSecondPass sp : dependencies ) { - String dependentTable = sp.getValue().getTable().getQuotedName(); + String dependentTable = quotedTableName(sp.getValue().getTable()); if ( dependentTable.compareTo( startTable ) == 0 ) { StringBuilder sb = new StringBuilder( "Foreign key circularity dependency involving the following tables: " @@ -1509,6 +1509,10 @@ public class Configuration implements Serializable { } } + private String quotedTableName(Table table) { + return Table.qualify( table.getCatalog(), table.getQuotedSchema(), table.getQuotedName() ); + } + private void processEndOfQueue(List endOfQueueFkSecondPasses) { /* * If a second pass raises a recoverableException, queue it for next round diff --git a/hibernate-core/src/test/java/org/hibernate/test/cfg/WrongCircularityDetectionTest.java b/hibernate-core/src/test/java/org/hibernate/test/cfg/WrongCircularityDetectionTest.java new file mode 100644 index 0000000000..6b66ce94f7 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/cfg/WrongCircularityDetectionTest.java @@ -0,0 +1,74 @@ +package org.hibernate.test.cfg; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import javax.persistence.Basic; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Table; + +import org.hibernate.cfg.Configuration; +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.junit4.BaseUnitTestCase; +import org.junit.Test; + +/** + * This test illustrates the problem when two related (in terms of joins) + * classes have the same table name in different schemas. + * + * @author Didier Villevalois + */ +@TestForIssue(jiraKey = "HHH-7134") +public class WrongCircularityDetectionTest extends BaseUnitTestCase { + + @Test + public void testNoCircularityDetection() { + Configuration cfg = new Configuration(); + cfg.addAnnotatedClass(Entity1.class); + cfg.addAnnotatedClass(Entity2.class); + + cfg.buildMappings(); + + org.hibernate.mapping.Table entity1Table = cfg.getClassMapping( + Entity1.class.getName()).getTable(); + org.hibernate.mapping.Table entity2Table = cfg.getClassMapping( + Entity2.class.getName()).getTable(); + + assertTrue(entity1Table.getName().equals(entity2Table.getName())); + assertFalse(entity1Table.getSchema().equals(entity2Table.getSchema())); + } + + @Entity + @Inheritance(strategy = InheritanceType.JOINED) + @Table(schema = "schema1", name = "entity") + public static class Entity1 { + private String id; + + @Id + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } + + @Entity + @Table(schema = "schema2", name = "entity") + public static class Entity2 extends Entity1 { + private String value; + + @Basic + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + } +} From 98ad44e75d78615d49f7ac3558db9df009a310da Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Fri, 31 Aug 2012 11:21:16 -0500 Subject: [PATCH 14/38] HHH-7563 - Fallback for JBossAppServerJtaPlatform.locateUserTransaction() to look at "java:jboss" if "java:comp" not available --- .../internal/AbstractJtaPlatform.java | 20 +++++++++-- .../internal/JBossAppServerJtaPlatform.java | 35 +++++++++++++++---- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java index fc997d6551..7ab85e783b 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java @@ -67,8 +67,24 @@ public abstract class AbstractJtaPlatform protected abstract UserTransaction locateUserTransaction(); public void configure(Map configValues) { - cacheTransactionManager = ConfigurationHelper.getBoolean( AvailableSettings.JTA_CACHE_TM, configValues, true ); - cacheUserTransaction = ConfigurationHelper.getBoolean( AvailableSettings.JTA_CACHE_UT, configValues, false ); + cacheTransactionManager = ConfigurationHelper.getBoolean( + AvailableSettings.JTA_CACHE_TM, + configValues, + canCacheTransactionManagerByDefault() + ); + cacheUserTransaction = ConfigurationHelper.getBoolean( + AvailableSettings.JTA_CACHE_UT, + configValues, + canCacheUserTransactionByDefault() + ); + } + + protected boolean canCacheTransactionManagerByDefault() { + return true; + } + + protected boolean canCacheUserTransactionByDefault() { + return false; } protected boolean canCacheTransactionManager() { diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java index 4ef9cf6f21..77c5a43afc 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java @@ -36,25 +36,46 @@ import org.hibernate.engine.jndi.JndiException; public class JBossAppServerJtaPlatform extends AbstractJtaPlatform { public static final String AS7_TM_NAME = "java:jboss/TransactionManager"; public static final String AS4_TM_NAME = "java:/TransactionManager"; - public static final String UT_NAME = "java:comp/UserTransaction"; // should work with AS7 and earlier + public static final String JBOSS__UT_NAME = "java:jboss/UserTransaction"; + public static final String UT_NAME = "java:comp/UserTransaction"; + + @Override + protected boolean canCacheUserTransactionByDefault() { + return true; + } + + @Override + protected boolean canCacheTransactionManagerByDefault() { + return true; + } @Override protected TransactionManager locateTransactionManager() { try { - return (TransactionManager) jndiService().locate(AS7_TM_NAME); + return (TransactionManager) jndiService().locate( AS7_TM_NAME ); } - catch(JndiException jndiException) { + catch (JndiException jndiException) { try { - return (TransactionManager) jndiService().locate(AS4_TM_NAME); + return (TransactionManager) jndiService().locate( AS4_TM_NAME ); } - catch(JndiException jndiExceptionInner) { - throw new JndiException("unable to find transaction manager", jndiException); + catch (JndiException jndiExceptionInner) { + throw new JndiException( "unable to find transaction manager", jndiException ); } } } @Override protected UserTransaction locateUserTransaction() { - return (UserTransaction) jndiService().locate( UT_NAME ); + try { + return (UserTransaction) jndiService().locate( JBOSS__UT_NAME ); + } + catch (JndiException jndiException) { + try { + return (UserTransaction) jndiService().locate( UT_NAME ); + } + catch (JndiException jndiExceptionInner) { + throw new JndiException( "unable to find UserTransaction", jndiException ); + } + } } } From ab64f5c3be0fbe757b49dfa7a39d9c2bf9903d80 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Fri, 31 Aug 2012 16:20:05 -0500 Subject: [PATCH 15/38] HHH-7552 - New StrategySelectorService : initial auto-detection --- .../BootstrapServiceRegistryBuilder.java | 21 +++++- .../boot/registry/selector/Availability.java | 33 +++++++++ .../selector/AvailabilityAnnouncer.java | 36 ++++++++++ .../selector/SimpleAvailabilityImpl.java | 66 ++++++++++++++++++ .../internal/StrategySelectorBuilder.java | 62 +++++++++-------- .../internal/NoCachingRegionFactory.java | 2 + .../internal/RegionFactoryInitiator.java | 58 +++++++++------- .../ehcache/AvailabilityAnnouncerImpl.java | 68 +++++++++++++++++++ ...ot.registry.selector.AvailabilityAnnouncer | 1 + .../infinispan/AvailabilityAnnouncerImpl.java | 65 ++++++++++++++++++ ...ot.registry.selector.AvailabilityAnnouncer | 0 11 files changed, 358 insertions(+), 54 deletions(-) create mode 100644 hibernate-core/src/main/java/org/hibernate/boot/registry/selector/Availability.java create mode 100644 hibernate-core/src/main/java/org/hibernate/boot/registry/selector/AvailabilityAnnouncer.java create mode 100644 hibernate-core/src/main/java/org/hibernate/boot/registry/selector/SimpleAvailabilityImpl.java create mode 100644 hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AvailabilityAnnouncerImpl.java create mode 100644 hibernate-ehcache/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.AvailabilityAnnouncer create mode 100644 hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/AvailabilityAnnouncerImpl.java create mode 100644 hibernate-infinispan/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.AvailabilityAnnouncer diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java index db33fef5eb..c8a97c0660 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java @@ -26,6 +26,8 @@ package org.hibernate.boot.registry; import java.util.LinkedHashSet; import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl; +import org.hibernate.boot.registry.selector.Availability; +import org.hibernate.boot.registry.selector.AvailabilityAnnouncer; import org.hibernate.integrator.internal.IntegratorServiceImpl; import org.hibernate.integrator.spi.Integrator; import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl; @@ -120,7 +122,24 @@ public class BootstrapServiceRegistryBuilder { */ @SuppressWarnings( {"UnusedDeclaration"}) public BootstrapServiceRegistryBuilder withStrategySelector(Class strategy, String name, Class implementation) { - this.strategySelectorBuilder.addCustomRegistration( strategy, name, implementation ); + this.strategySelectorBuilder.addExplicitAvailability( strategy, implementation, name ); + return this; + } + + /** + * Applies one or more strategy selectors announced as available by the passed announcer. + * + * @param availabilityAnnouncer An announcer for one or more available selectors + * + * @return {@code this}, for method chaining + * + * @see org.hibernate.boot.registry.selector.spi.StrategySelector#registerStrategyImplementor(Class, String, Class) + */ + @SuppressWarnings( {"UnusedDeclaration"}) + public BootstrapServiceRegistryBuilder withStrategySelectors(AvailabilityAnnouncer availabilityAnnouncer) { + for ( Availability availability : availabilityAnnouncer.getAvailabilities() ) { + this.strategySelectorBuilder.addExplicitAvailability( availability ); + } return this; } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/Availability.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/Availability.java new file mode 100644 index 0000000000..658bbb7bed --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/Availability.java @@ -0,0 +1,33 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.boot.registry.selector; + +/** + * @author Steve Ebersole + */ +public interface Availability { + public Class getStrategyRole(); + public Iterable getSelectorNames(); + public Class getStrategyImplementation(); +} diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/AvailabilityAnnouncer.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/AvailabilityAnnouncer.java new file mode 100644 index 0000000000..eddc5b3e7e --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/AvailabilityAnnouncer.java @@ -0,0 +1,36 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.boot.registry.selector; + +/** + * Responsible for announcing the availability of strategy selector(s). Can be registered directly with the + * {@link org.hibernate.boot.registry.BootstrapServiceRegistry} or located via discovery + * + * todo : better name? + * + * @author Steve Ebersole + */ +public interface AvailabilityAnnouncer { + public Iterable getAvailabilities(); +} diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/SimpleAvailabilityImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/SimpleAvailabilityImpl.java new file mode 100644 index 0000000000..ad515ce1ab --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/SimpleAvailabilityImpl.java @@ -0,0 +1,66 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.boot.registry.selector; + +import java.util.Arrays; + +/** + * @author Steve Ebersole + */ +public class SimpleAvailabilityImpl implements Availability { + private final Class strategyRole; + private final Class strategyImplementation; + private final Iterable selectorNames; + + public SimpleAvailabilityImpl( + Class strategyRole, + Class strategyImplementation, + Iterable selectorNames) { + this.strategyRole = strategyRole; + this.strategyImplementation = strategyImplementation; + this.selectorNames = selectorNames; + } + + public SimpleAvailabilityImpl( + Class strategyRole, + Class strategyImplementation, + String... selectorNames) { + this( strategyRole, strategyImplementation, Arrays.asList( selectorNames ) ); + } + + @Override + public Class getStrategyRole() { + return strategyRole; + } + + @Override + public Iterable getSelectorNames() { + return selectorNames; + } + + @Override + public Class getStrategyImplementation() { + return strategyImplementation; + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java index cf35ce47e8..6404478a06 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java @@ -29,6 +29,9 @@ import java.util.List; import org.jboss.logging.Logger; import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl; +import org.hibernate.boot.registry.selector.Availability; +import org.hibernate.boot.registry.selector.AvailabilityAnnouncer; +import org.hibernate.boot.registry.selector.SimpleAvailabilityImpl; import org.hibernate.boot.registry.selector.spi.StrategySelectionException; import org.hibernate.boot.registry.selector.spi.StrategySelector; import org.hibernate.dialect.CUBRIDDialect; @@ -98,38 +101,27 @@ import org.hibernate.engine.transaction.spi.TransactionFactory; public class StrategySelectorBuilder { private static final Logger log = Logger.getLogger( StrategySelectorBuilder.class ); - private static class CustomRegistration { - private final Class strategy; - private final String name; - private final Class implementation; - - private CustomRegistration(Class strategy, String name, Class implementation) { - this.strategy = strategy; - this.name = name; - this.implementation = implementation; - } - - public void registerWith(StrategySelectorImpl strategySelector) { - strategySelector.registerStrategyImplementor( strategy, name, implementation ); - } - } - - private final List customRegistrations = new ArrayList(); + private final List explicitAvailabilities = new ArrayList(); @SuppressWarnings("unchecked") - public void addCustomRegistration(Class strategy, String name, Class implementation) { - if ( !strategy.isInterface() ) { + public void addExplicitAvailability(Class strategy, Class implementation, String name) { + addExplicitAvailability( new SimpleAvailabilityImpl( strategy, implementation, name ) ); + } + + public void addExplicitAvailability(Availability availability) { + if ( !availability.getStrategyRole().isInterface() ) { // not good form... - log.debug( "Registering non-interface strategy implementation : " + strategy.getName() ); + log.debug( "Registering non-interface strategy implementation : " + availability.getStrategyRole().getName() ); } - if ( ! strategy.isAssignableFrom( implementation ) ) { + if ( ! availability.getStrategyRole().isAssignableFrom( availability.getStrategyImplementation() ) ) { throw new StrategySelectionException( - "Implementation class [" + implementation.getName() + "] does not implement strategy interface [" - + strategy.getName() + "]" + "Implementation class [" + availability.getStrategyImplementation().getName() + + "] does not implement strategy interface [" + + availability.getStrategyRole().getName() + "]" ); } - customRegistrations.add( new CustomRegistration( strategy, name, implementation ) ); + explicitAvailabilities.add( availability ); } public StrategySelector buildSelector(ClassLoaderServiceImpl classLoaderService) { @@ -140,16 +132,32 @@ public class StrategySelectorBuilder { addJtaPlatforms( strategySelector ); addTransactionFactories( strategySelector ); - // todo : apply auto-discovered registrations + // apply auto-discovered registrations + for ( AvailabilityAnnouncer announcer : classLoaderService.loadJavaServices( AvailabilityAnnouncer.class ) ) { + for ( Availability discoveredAvailability : announcer.getAvailabilities() ) { + applyFromAvailability( strategySelector, discoveredAvailability ); + } + } // apply customizations - for ( CustomRegistration customRegistration : customRegistrations ) { - customRegistration.registerWith( strategySelector ); + for ( Availability explicitAvailability : explicitAvailabilities ) { + applyFromAvailability( strategySelector, explicitAvailability ); } return strategySelector; } + @SuppressWarnings("unchecked") + private void applyFromAvailability(StrategySelectorImpl strategySelector, Availability availability) { + for ( String name : availability.getSelectorNames() ) { + strategySelector.registerStrategyImplementor( + availability.getStrategyRole(), + name, + availability.getStrategyImplementation() + ); + } + } + private void addDialects(StrategySelectorImpl strategySelector) { addDialect( strategySelector, Cache71Dialect.class ); addDialect( strategySelector, CUBRIDDialect.class ); diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java index 94a4a59201..7d16fb3e5a 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java @@ -43,6 +43,8 @@ import org.hibernate.cfg.Settings; * @author Steve Ebersole */ public class NoCachingRegionFactory implements RegionFactory { + public static final NoCachingRegionFactory INSTANCE = new NoCachingRegionFactory(); + public NoCachingRegionFactory() { } diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java index 6a2002f591..65b13cb453 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java @@ -26,6 +26,7 @@ package org.hibernate.cache.internal; import java.util.Map; import org.hibernate.boot.registry.StandardServiceInitiator; +import org.hibernate.boot.registry.selector.spi.StrategySelector; import org.hibernate.cache.spi.RegionFactory; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.service.spi.ServiceException; @@ -52,32 +53,37 @@ public class RegionFactoryInitiator implements StandardServiceInitiator customImplClass = null; - if ( Class.class.isInstance( impl ) ) { - customImplClass = (Class) impl; - } - else { - customImplClass = registry.getService( ClassLoaderService.class ) - .classForName( mapLegacyNames( impl.toString() ) ); - } - - try { - return customImplClass.newInstance(); - } - catch ( Exception e ) { - throw new ServiceException( - "Could not initialize custom RegionFactory impl [" + customImplClass.getName() + "]", e - ); - } + final Object setting = configurationValues.get( IMPL_NAME ); + return registry.getService( StrategySelector.class ).resolveDefaultableStrategy( + RegionFactory.class, + setting, + NoCachingRegionFactory.INSTANCE + ); +// if ( setting == null ) { +// return new NoCachingRegionFactory(); +// } +// +// if ( getServiceInitiated().isInstance( setting ) ) { +// return (RegionFactory) setting; +// } +// +// Class customImplClass = null; +// if ( Class.class.isInstance( setting ) ) { +// customImplClass = (Class) setting; +// } +// else { +// customImplClass = registry.getService( ClassLoaderService.class ) +// .classForName( mapLegacyNames( setting.toString() ) ); +// } +// +// try { +// return customImplClass.newInstance(); +// } +// catch ( Exception e ) { +// throw new ServiceException( +// "Could not initialize custom RegionFactory impl [" + customImplClass.getName() + "]", e +// ); +// } } // todo this shouldn't be public (nor really static): diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AvailabilityAnnouncerImpl.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AvailabilityAnnouncerImpl.java new file mode 100644 index 0000000000..9efe6fa462 --- /dev/null +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AvailabilityAnnouncerImpl.java @@ -0,0 +1,68 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.cache.ehcache; + +import java.util.ArrayList; +import java.util.List; + +import org.hibernate.boot.registry.selector.Availability; +import org.hibernate.boot.registry.selector.AvailabilityAnnouncer; +import org.hibernate.boot.registry.selector.SimpleAvailabilityImpl; +import org.hibernate.cache.spi.RegionFactory; + +/** + * Makes the 2 contained region factory implementations available to the Hibernate + * {@link org.hibernate.boot.registry.selector.spi.StrategySelector} service. + * + * @author Steve Ebersole + */ +public class AvailabilityAnnouncerImpl implements AvailabilityAnnouncer { + @Override + @SuppressWarnings("unchecked") + public Iterable getAvailabilities() { + final List availabilities = new ArrayList(); + + availabilities.add( + new SimpleAvailabilityImpl( + RegionFactory.class, + EhCacheRegionFactory.class, + "ehcache", + EhCacheRegionFactory.class.getSimpleName(), + "org.hibernate.cache.EhCacheRegionFactory" // legacy impl class name + ) + ); + + availabilities.add( + new SimpleAvailabilityImpl( + RegionFactory.class, + SingletonEhCacheRegionFactory.class, + "ehcache-singleton", + SingletonEhCacheRegionFactory.class.getSimpleName(), + "org.hibernate.cache.SingletonEhCacheRegionFactory" // legacy impl class name + ) + ); + + return availabilities; + } +} diff --git a/hibernate-ehcache/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.AvailabilityAnnouncer b/hibernate-ehcache/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.AvailabilityAnnouncer new file mode 100644 index 0000000000..4089ec9f31 --- /dev/null +++ b/hibernate-ehcache/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.AvailabilityAnnouncer @@ -0,0 +1 @@ +org.hibernate.cache.ehcache.AvailabilityAnnouncerImpl \ No newline at end of file diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/AvailabilityAnnouncerImpl.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/AvailabilityAnnouncerImpl.java new file mode 100644 index 0000000000..fc6ad8eccd --- /dev/null +++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/AvailabilityAnnouncerImpl.java @@ -0,0 +1,65 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.cache.infinispan; + +import java.util.ArrayList; +import java.util.List; + +import org.hibernate.boot.registry.selector.Availability; +import org.hibernate.boot.registry.selector.AvailabilityAnnouncer; +import org.hibernate.boot.registry.selector.SimpleAvailabilityImpl; +import org.hibernate.cache.spi.RegionFactory; + +/** + * Makes the 2 contained region factory implementations available to the Hibernate + * {@link org.hibernate.boot.registry.selector.spi.StrategySelector} service. + * + * @author Steve Ebersole + */ +public class AvailabilityAnnouncerImpl implements AvailabilityAnnouncer { + @Override + public Iterable getAvailabilities() { + final List availabilities = new ArrayList(); + + availabilities.add( + new SimpleAvailabilityImpl( + RegionFactory.class, + InfinispanRegionFactory.class, + "infinispan", + InfinispanRegionFactory.class.getSimpleName() + ) + ); + + availabilities.add( + new SimpleAvailabilityImpl( + RegionFactory.class, + JndiInfinispanRegionFactory.class, + "infinispan-jndi", + JndiInfinispanRegionFactory.class.getSimpleName() + ) + ); + + return availabilities; + } +} diff --git a/hibernate-infinispan/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.AvailabilityAnnouncer b/hibernate-infinispan/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.AvailabilityAnnouncer new file mode 100644 index 0000000000..e69de29bb2 From 076eccb7a21d8cdbc820a5d089645fabe9d6b933 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 3 Sep 2012 22:06:23 -0500 Subject: [PATCH 16/38] HHH-5188 - Use provided enum type ordinal/string when reading --- .../java/org/hibernate/type/EnumType.java | 437 ++++++++++++------ .../usertype/DynamicParameterizedType.java | 25 +- .../nested/NestedEmbeddableMetadataTest.java | 7 +- .../testing/junit4/ExtraAssertions.java | 48 ++ 4 files changed, 377 insertions(+), 140 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/type/EnumType.java b/hibernate-core/src/main/java/org/hibernate/type/EnumType.java index 809948c80f..0cf1a17d5f 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/EnumType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/EnumType.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * Copyright (c) 2008, 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 @@ -23,6 +23,8 @@ */ package org.hibernate.type; +import javax.persistence.Enumerated; +import javax.persistence.MapKeyEnumerated; import java.io.Serializable; import java.lang.annotation.Annotation; import java.sql.PreparedStatement; @@ -30,163 +32,155 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import java.util.Properties; -import javax.persistence.Enumerated; -import javax.persistence.MapKeyEnumerated; + +import org.jboss.logging.Logger; + import org.hibernate.AssertionFailure; import org.hibernate.HibernateException; import org.hibernate.engine.spi.SessionImplementor; -import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.ReflectHelper; +import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.usertype.DynamicParameterizedType; import org.hibernate.usertype.EnhancedUserType; -import org.jboss.logging.Logger; /** - * Enum type mapper - * Try and find the appropriate SQL type depending on column metadata - *

    - * TODO implements readobject/writeobject to recalculate the enumclasses + * Value type mapper for enumerations. + * + * Generally speaking, the proper configuration is picked up from the annotations associated with the mapped attribute. + * + * There are a few configuration parameters understood by this type mapper:

      + *
    • + * enumClass - Names the enumeration class. + *
    • + *
    • + * useNamed - Should enum be mapped via name. Default is to map as ordinal. Used when + * annotations are not used (otherwise {@link javax.persistence.EnumType} is used). + *
    • + *
    • + * type - Identifies the JDBC type (via type code) to be used for the column. + *
    • + *
    * * @author Emmanuel Bernard * @author Hardy Ferentschik + * @author Steve Ebersole */ @SuppressWarnings("unchecked") public class EnumType implements EnhancedUserType, DynamicParameterizedType, Serializable { - - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, EnumType.class.getName()); + private static final Logger LOG = Logger.getLogger( EnumType.class.getName() ); public static final String ENUM = "enumClass"; - public static final String SCHEMA = "schema"; - public static final String CATALOG = "catalog"; - public static final String TABLE = "table"; - public static final String COLUMN = "column"; + public static final String NAMED = "useNamed"; public static final String TYPE = "type"; private Class enumClass; - private transient Object[] enumValues; - private int sqlType = Types.INTEGER; //before any guessing + private EnumValueMapper enumValueMapper; + private int sqlType = Types.INTEGER; // before any guessing + @Override public int[] sqlTypes() { return new int[] { sqlType }; } + @Override public Class returnedClass() { return enumClass; } + @Override public boolean equals(Object x, Object y) throws HibernateException { return x == y; } + @Override public int hashCode(Object x) throws HibernateException { return x == null ? 0 : x.hashCode(); } - - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { - Object object = rs.getObject( names[0] ); - if ( rs.wasNull() ) { - if ( LOG.isTraceEnabled() ) LOG.tracev( "Returning null as column {0}", names[0] ); - return null; + @Override + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException { + if ( enumValueMapper == null ) { + guessTypeOfEnumValueMapper( rs.getMetaData().getColumnType( rs.findColumn( names[0] ) ) ); } - if ( object instanceof Number ) { - initEnumValues(); - int ordinal = ( ( Number ) object ).intValue(); - if (ordinal < 0 || ordinal >= enumValues.length) throw new IllegalArgumentException("Unknown ordinal value for enum " - + enumClass + ": " + ordinal); - if ( LOG.isTraceEnabled() ) LOG.tracev( "Returning '{0}' as column {1}", ordinal, names[0] ); - return enumValues[ordinal]; + return enumValueMapper.getValue( rs, names ); + } + + private void guessTypeOfEnumValueMapper(int columnType) { + // fallback for cases where not enough parameter/parameterization information was passed in + if ( isOrdinal( columnType ) ) { + treatAsOrdinal(); } else { - String name = ( String ) object; - if ( LOG.isTraceEnabled() ) LOG.tracev( "Returning '{0}' as column {1}", name, names[0] ); - try { - return Enum.valueOf( enumClass, name ); - } - catch ( IllegalArgumentException iae ) { - throw new IllegalArgumentException( "Unknown name value for enum " + enumClass + ": " + name, iae ); - } + treatAsNamed(); } } + @Override public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { - if ( value == null ) { - if ( LOG.isTraceEnabled() ) LOG.tracev( "Binding null to parameter: {0}", index ); - st.setNull( index, sqlType ); - } - else { - boolean isOrdinal = isOrdinal( sqlType ); - if ( isOrdinal ) { - int ordinal = ( ( Enum ) value ).ordinal(); - if ( LOG.isTraceEnabled() ) LOG.tracev( "Binding '{0}' to parameter: '{1}", ordinal, index ); - st.setObject( index, Integer.valueOf( ordinal ), sqlType ); - } - else { - String enumString = ( ( Enum ) value ).name(); - if ( LOG.isTraceEnabled() ) LOG.tracev( "Binding '{0}' to parameter: {1}", enumString, index ); - st.setObject( index, enumString, sqlType ); - } - } - } - - private boolean isOrdinal(int paramType) { - switch ( paramType ) { - case Types.INTEGER: - case Types.NUMERIC: - case Types.SMALLINT: - case Types.TINYINT: - case Types.BIGINT: - case Types.DECIMAL: //for Oracle Driver - case Types.DOUBLE: //for Oracle Driver - case Types.FLOAT: //for Oracle Driver - return true; - case Types.CHAR: - case Types.LONGVARCHAR: - case Types.VARCHAR: - return false; - default: - throw new HibernateException( "Unable to persist an Enum in a column of SQL Type: " + paramType ); + if ( enumValueMapper == null ) { + guessTypeOfEnumValueMapper( st.getParameterMetaData().getParameterType( index ) ); } + enumValueMapper.setValue( st, (Enum) value, index ); } + @Override public Object deepCopy(Object value) throws HibernateException { return value; } + @Override public boolean isMutable() { return false; } + @Override public Serializable disassemble(Object value) throws HibernateException { return ( Serializable ) value; } + @Override public Object assemble(Serializable cached, Object owner) throws HibernateException { return cached; } + @Override public Object replace(Object original, Object target, Object owner) throws HibernateException { return original; } + @Override public void setParameterValues(Properties parameters) { - ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE ); + final ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE ); + + // IMPL NOTE : be protective about not setting enumValueMapper (i.e. calling treatAsNamed/treatAsOrdinal) + // in cases where we do not have enough information. In such cases the `if` check in nullSafeGet/nullSafeSet + // will kick in to query against the JDBC metadata to make that determination. if ( reader != null ) { enumClass = reader.getReturnedClass().asSubclass( Enum.class ); - javax.persistence.EnumType enumType = getEnumType( reader ); - if ( enumType != null ) { - if ( javax.persistence.EnumType.ORDINAL.equals( enumType ) ) { - sqlType = Types.INTEGER; - } - else if ( javax.persistence.EnumType.STRING.equals( enumType ) ) { - sqlType = Types.VARCHAR; - } - else { - throw new AssertionFailure( "Unknown EnumType: " + enumType ); - } + final boolean isOrdinal; + final javax.persistence.EnumType enumType = getEnumType( reader ); + if ( enumType == null ) { + isOrdinal = true; } + else if ( javax.persistence.EnumType.ORDINAL.equals( enumType ) ) { + isOrdinal = true; + } + else if ( javax.persistence.EnumType.STRING.equals( enumType ) ) { + isOrdinal = false; + } + else { + throw new AssertionFailure( "Unknown EnumType: " + enumType ); + } + + if ( isOrdinal ) { + treatAsOrdinal(); + } + else { + treatAsNamed(); + } + sqlType = enumValueMapper.getSqlType(); } else { String enumClassName = (String) parameters.get( ENUM ); @@ -197,63 +191,34 @@ public class EnumType implements EnhancedUserType, DynamicParameterizedType, Ser throw new HibernateException( "Enum class not found", exception ); } - String type = (String) parameters.get( TYPE ); - if ( type != null ) { - sqlType = Integer.decode( type ); + final Object useNamedSetting = parameters.get( NAMED ); + if ( useNamedSetting != null ) { + final boolean useNamed = ConfigurationHelper.getBoolean( NAMED, parameters ); + if ( useNamed ) { + treatAsNamed(); + } + else { + treatAsOrdinal(); + } + sqlType = enumValueMapper.getSqlType(); } } + + final String type = (String) parameters.get( TYPE ); + if ( type != null ) { + sqlType = Integer.decode( type ); + } } - /** - * Lazy init of {@link #enumValues}. - */ - private void initEnumValues() { - if ( enumValues == null ) { - this.enumValues = enumClass.getEnumConstants(); - if ( enumValues == null ) { - throw new NullPointerException( "Failed to init enumValues" ); - } + private void treatAsOrdinal() { + if ( enumValueMapper == null || ! OrdinalEnumValueMapper.class.isInstance( enumValueMapper ) ) { + enumValueMapper = new OrdinalEnumValueMapper(); } } - public String objectToSQLString(Object value) { - boolean isOrdinal = isOrdinal( sqlType ); - if ( isOrdinal ) { - int ordinal = ( ( Enum ) value ).ordinal(); - return Integer.toString( ordinal ); - } - else { - return '\'' + ( ( Enum ) value ).name() + '\''; - } - } - - public String toXMLString(Object value) { - boolean isOrdinal = isOrdinal( sqlType ); - if ( isOrdinal ) { - int ordinal = ( ( Enum ) value ).ordinal(); - return Integer.toString( ordinal ); - } - else { - return ( ( Enum ) value ).name(); - } - } - - public Object fromXMLString(String xmlValue) { - try { - int ordinal = Integer.parseInt( xmlValue ); - initEnumValues(); - if ( ordinal < 0 || ordinal >= enumValues.length ) { - throw new IllegalArgumentException( "Unknown ordinal value for enum " + enumClass + ": " + ordinal ); - } - return enumValues[ordinal]; - } - catch ( NumberFormatException e ) { - try { - return Enum.valueOf( enumClass, xmlValue ); - } - catch ( IllegalArgumentException iae ) { - throw new IllegalArgumentException( "Unknown name value for enum " + enumClass + ": " + xmlValue, iae ); - } + private void treatAsNamed() { + if ( enumValueMapper == null || ! NamedEnumValueMapper.class.isInstance( enumValueMapper ) ) { + enumValueMapper = new NamedEnumValueMapper(); } } @@ -282,4 +247,202 @@ public class EnumType implements EnhancedUserType, DynamicParameterizedType, Ser } return null; } + + @Override + public String objectToSQLString(Object value) { + return enumValueMapper.objectToSQLString( (Enum) value ); + } + + @Override + public String toXMLString(Object value) { + return enumValueMapper.toXMLString( (Enum) value ); + } + + @Override + public Object fromXMLString(String xmlValue) { + return enumValueMapper.fromXMLString( xmlValue ); + } + + private static interface EnumValueMapper { + public int getSqlType(); + public Enum getValue(ResultSet rs, String[] names) throws SQLException; + public void setValue(PreparedStatement st, Enum value, int index) throws SQLException; + + public String objectToSQLString(Enum value); + public String toXMLString(Enum value); + public Enum fromXMLString(String xml); + } + + public abstract class EnumValueMapperSupport implements EnumValueMapper { + protected abstract Object extractJdbcValue(Enum value); + + @Override + public void setValue(PreparedStatement st, Enum value, int index) throws SQLException { + final Object jdbcValue = value == null ? null : extractJdbcValue( value ); + + if ( jdbcValue == null ) { + if ( LOG.isTraceEnabled() ) { + LOG.tracev( "Binding null to parameter: {0}", index ); + } + st.setNull( index, getSqlType() ); + return; + } + + if ( LOG.isTraceEnabled() ) { + LOG.tracev( "Binding '{0}' to parameter: '{1}", jdbcValue, index ); + } + st.setObject( index, jdbcValue, EnumType.this.sqlType ); + } + } + + private class OrdinalEnumValueMapper extends EnumValueMapperSupport implements EnumValueMapper { + private transient Enum[] enumsByOrdinal; + + @Override + public int getSqlType() { + return Types.INTEGER; + } + + @Override + public Enum getValue(ResultSet rs, String[] names) throws SQLException { + final int ordinal = rs.getInt( names[0] ); + if ( rs.wasNull() ) { + if ( LOG.isTraceEnabled() ) { + LOG.tracev( "Returning null as column {0}", names[0] ); + } + return null; + } + + final Enum enumValue = fromOrdinal( ordinal ); + if ( LOG.isTraceEnabled() ) { + LOG.tracev( "Returning '{0}' as column {1}", enumValue, names[0] ); + } + return enumValue; + } + + private Enum fromOrdinal(int ordinal) { + final Enum[] enumsByOrdinal = enumsByOrdinal(); + if ( ordinal < 0 || ordinal >= enumsByOrdinal.length ) { + throw new IllegalArgumentException( + String.format( + "Unknown ordinal value [%s] for enum class [%s]", + ordinal, + enumClass.getName() + ) + ); + } + return enumsByOrdinal[ordinal]; + + } + + private Enum[] enumsByOrdinal() { + if ( enumsByOrdinal == null ) { + enumsByOrdinal = enumClass.getEnumConstants(); + if ( enumsByOrdinal == null ) { + throw new HibernateException( "Failed to init enum values" ); + } + } + return enumsByOrdinal; + } + + @Override + public String objectToSQLString(Enum value) { + return toXMLString( value ); + } + + @Override + public String toXMLString(Enum value) { + return Integer.toString( value.ordinal() ); + } + + @Override + public Enum fromXMLString(String xml) { + return fromOrdinal( Integer.parseInt( xml ) ); + } + + @Override + protected Object extractJdbcValue(Enum value) { + return value.ordinal(); + } + } + + private class NamedEnumValueMapper extends EnumValueMapperSupport implements EnumValueMapper { + @Override + public int getSqlType() { + return Types.VARCHAR; + } + + @Override + public Enum getValue(ResultSet rs, String[] names) throws SQLException { + final String value = rs.getString( names[0] ); + + if ( rs.wasNull() ) { + if ( LOG.isTraceEnabled() ) { + LOG.tracev( "Returning null as column {0}", names[0] ); + } + return null; + } + + final Enum enumValue = fromName( value ); + if ( LOG.isTraceEnabled() ) { + LOG.tracev( "Returning '{0}' as column {1}", enumValue, names[0] ); + } + return enumValue; + } + + private Enum fromName(String name) { + try { + return Enum.valueOf( enumClass, name ); + } + catch ( IllegalArgumentException iae ) { + throw new IllegalArgumentException( + String.format( + "Unknown name value [%s] for enum class [%s]", + name, + enumClass.getName() + ) + ); + } + } + + @Override + public String objectToSQLString(Enum value) { + return '\'' + toXMLString( value ) + '\''; + } + + @Override + public String toXMLString(Enum value) { + return value.name(); + } + + @Override + public Enum fromXMLString(String xml) { + return fromName( xml ); + } + + @Override + protected Object extractJdbcValue(Enum value) { + return value.name(); + } + } + + private boolean isOrdinal(int paramType) { + switch ( paramType ) { + case Types.INTEGER: + case Types.NUMERIC: + case Types.SMALLINT: + case Types.TINYINT: + case Types.BIGINT: + case Types.DECIMAL: //for Oracle Driver + case Types.DOUBLE: //for Oracle Driver + case Types.FLOAT: //for Oracle Driver + return true; + case Types.CHAR: + case Types.LONGVARCHAR: + case Types.VARCHAR: + return false; + default: + throw new HibernateException( "Unable to persist an Enum in a column of SQL Type: " + paramType ); + } + } } diff --git a/hibernate-core/src/main/java/org/hibernate/usertype/DynamicParameterizedType.java b/hibernate-core/src/main/java/org/hibernate/usertype/DynamicParameterizedType.java index 6b072c3611..07043eda19 100644 --- a/hibernate-core/src/main/java/org/hibernate/usertype/DynamicParameterizedType.java +++ b/hibernate-core/src/main/java/org/hibernate/usertype/DynamicParameterizedType.java @@ -1,10 +1,31 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.usertype; import java.lang.annotation.Annotation; /** - * {@inheritDoc} - * * Types who implements this interface will have in the setParameterValues an * instance of the class DynamicParameterizedType$ParameterType instead of * the key PARAMETER_TYPE = "org.hibernate.type.ParameterType" diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/nested/NestedEmbeddableMetadataTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/nested/NestedEmbeddableMetadataTest.java index 062f862f7d..e8a36f10ca 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/nested/NestedEmbeddableMetadataTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/nested/NestedEmbeddableMetadataTest.java @@ -23,7 +23,11 @@ */ package org.hibernate.test.annotations.embeddables.nested; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.sql.Types; +import java.util.HashMap; +import java.util.Map; import org.junit.Test; @@ -37,6 +41,7 @@ import org.hibernate.mapping.SimpleValue; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.type.CustomType; +import static org.hibernate.testing.junit4.ExtraAssertions.assertJdbcTypeCode; import static org.junit.Assert.assertEquals; /** @@ -57,6 +62,6 @@ public class NestedEmbeddableMetadataTest extends BaseUnitTestCase { CustomType currencyType = (CustomType) currencyMetadata.getType(); int[] currencySqlTypes = currencyType.sqlTypes( mapping ); assertEquals( 1, currencySqlTypes.length ); - assertEquals( Types.VARCHAR, currencySqlTypes[0] ); + assertJdbcTypeCode( Types.VARCHAR, currencySqlTypes[0] ); } } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/ExtraAssertions.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/ExtraAssertions.java index f80b801194..7866276c2d 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/ExtraAssertions.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/ExtraAssertions.java @@ -23,8 +23,16 @@ */ package org.hibernate.testing.junit4; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.sql.Types; +import java.util.HashMap; +import java.util.Map; + import org.junit.Assert; +import static org.junit.Assert.fail; + /** * @author Steve Ebersole */ @@ -51,4 +59,44 @@ public class ExtraAssertions { } return (T) value; } + + public static void assertJdbcTypeCode(int expected, int actual) { + if ( expected != actual ) { + final String message = String.format( + "JDBC type codes did not match...\n" + + "Expected: %s (%s)\n" + + "Actual : %s (%s)", + jdbcTypeCodeMap().get( expected ), + expected, + jdbcTypeCodeMap().get( actual ), + actual + ); + fail( message ); + } + } + + private static Map jdbcTypeCodeMap; + + private static synchronized Map jdbcTypeCodeMap() { + if ( jdbcTypeCodeMap == null ) { + jdbcTypeCodeMap = generateJdbcTypeCache(); + } + return jdbcTypeCodeMap; + } + + private static Map generateJdbcTypeCache() { + final Field[] fields = Types.class.getFields(); + Map cache = new HashMap( (int)( fields.length * .75 ) + 1 ); + for ( int i = 0; i < fields.length; i++ ) { + final Field field = fields[i]; + if ( Modifier.isStatic( field.getModifiers() ) ) { + try { + cache.put( field.get( null ), field.getName() ); + } + catch ( Throwable ignore ) { + } + } + } + return cache; + } } From 4450b127b2a03b4841d3e1e6a08d7f45dd602c16 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Tue, 4 Sep 2012 12:17:34 -0500 Subject: [PATCH 17/38] HHH-7567 - Better checking when @Enumerated involved --- .../org/hibernate/cfg/AnnotationBinder.java | 2 +- .../cfg/annotations/CollectionBinder.java | 4 +- .../hibernate/cfg/annotations/MapBinder.java | 2 +- .../cfg/annotations/PropertyBinder.java | 2 +- .../cfg/annotations/SimpleValueBinder.java | 18 +++++- .../enums/InvalidEnumeratedJavaTypeTest.java | 61 +++++++++++++++++++ 6 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/enums/InvalidEnumeratedJavaTypeTest.java diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java index bdd7c68499..5ff2bd768f 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java @@ -2495,7 +2495,7 @@ public final class AnnotationBinder { value.setColumns( columns ); value.setPersistentClassName( persistentClassName ); value.setMappings( mappings ); - value.setType( inferredData.getProperty(), inferredData.getClassOrElement() ); + value.setType( inferredData.getProperty(), inferredData.getClassOrElement(), persistentClassName ); value.setAccessType( propertyAccessor ); id = value.make(); } diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java index 1e663cb879..560d3ec935 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java @@ -1288,7 +1288,7 @@ public abstract class CollectionBinder { column.setTable( collValue.getCollectionTable() ); } elementBinder.setColumns( elementColumns ); - elementBinder.setType( property, elementClass ); + elementBinder.setType( property, elementClass, collValue.getOwnerEntityName() ); elementBinder.setPersistentClassName( propertyHolder.getEntityName() ); elementBinder.setAccessType( accessType ); collValue.setElement( elementBinder.make() ); @@ -1441,4 +1441,4 @@ public abstract class CollectionBinder { public void setLocalGenerators(HashMap localGenerators) { this.localGenerators = localGenerators; } -} +} \ No newline at end of file diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java index d62ddc3fb0..4883499bf5 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java @@ -282,7 +282,7 @@ public class MapBinder extends CollectionBinder { elementBinder.setExplicitType( mapKeyTypeAnnotation.value() ); } else { - elementBinder.setType( property, elementClass ); + elementBinder.setType( property, elementClass, this.collection.getOwnerEntityName() ); } elementBinder.setPersistentClassName( propertyHolder.getEntityName() ); elementBinder.setAccessType( accessType ); diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java index b4251816b7..27e9235a89 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java @@ -185,7 +185,7 @@ public class PropertyBinder { simpleValueBinder.setReturnedClassName( returnedClassName ); simpleValueBinder.setColumns( columns ); simpleValueBinder.setPersistentClassName( containerClassName ); - simpleValueBinder.setType( property, returnedClass ); + simpleValueBinder.setType( property, returnedClass, containerClassName ); simpleValueBinder.setMappings( mappings ); simpleValueBinder.setReferencedEntityName( referencedEntityName ); simpleValueBinder.setAccessType( accessType ); diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java index 1a5c7b90c8..1fede49a0f 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java @@ -140,10 +140,11 @@ public class SimpleValueBinder { //TODO execute it lazily to be order safe - public void setType(XProperty property, XClass returnedClass) { + public void setType(XProperty property, XClass returnedClass, String declaringClassName) { if ( returnedClass == null ) { + // we cannot guess anything return; - } //we cannot guess anything + } XClass returnedClassOrElement = returnedClass; boolean isArray = false; if ( property.isArray() ) { @@ -237,6 +238,17 @@ public class SimpleValueBinder { } else if ( ( !key && property.isAnnotationPresent( Enumerated.class ) ) || ( key && property.isAnnotationPresent( MapKeyEnumerated.class ) ) ) { + final Class attributeJavaType = mappings.getReflectionManager().toClass( returnedClassOrElement ); + if ( !Enum.class.isAssignableFrom( attributeJavaType ) ) { + throw new AnnotationException( + String.format( + "Attribute [%s.%s] was annotated as enumerated, but its java type is not an enum [%s]", + declaringClassName, + xproperty.getName(), + attributeJavaType.getName() + ) + ); + } type = EnumType.class.getName(); explicitType = type; } @@ -625,4 +637,4 @@ public class SimpleValueBinder { public void setAccessType(AccessType accessType) { this.accessType = accessType; } -} \ No newline at end of file +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/enums/InvalidEnumeratedJavaTypeTest.java b/hibernate-core/src/test/java/org/hibernate/test/enums/InvalidEnumeratedJavaTypeTest.java new file mode 100644 index 0000000000..a26dd02205 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/enums/InvalidEnumeratedJavaTypeTest.java @@ -0,0 +1,61 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.enums; + +import javax.persistence.Entity; +import javax.persistence.Enumerated; +import javax.persistence.Id; + +import org.hibernate.AnnotationException; +import org.hibernate.cfg.Configuration; + +import org.junit.Test; + +import org.hibernate.testing.junit4.BaseUnitTestCase; + +import static org.junit.Assert.fail; + +/** + * @author Steve Ebersole + */ +public class InvalidEnumeratedJavaTypeTest extends BaseUnitTestCase { + @Test + public void testInvalidMapping() { + final Configuration cfg = new Configuration(); + try { + cfg.addAnnotatedClass( TheEntity.class ); + cfg.buildMappings(); + fail( "Was expecting failure" ); + } + catch (AnnotationException expected) { + System.out.println( expected ); + } + } + + @Entity + public static class TheEntity { + @Id private Long id; + @Enumerated private Boolean yesNo; + } +} From 54f433541671da649d3ca8fe28c8fbbcd3c32f04 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Tue, 4 Sep 2012 15:00:48 -0500 Subject: [PATCH 18/38] HHH-7203 - IdentityGenerator fails with JOINED Inheritance when inserting entity to PosgtreSQL --- .../org/hibernate/id/IdentityGenerator.java | 6 +- .../id/SequenceIdentityGenerator.java | 2 +- ...ssHierarchyWithIdentityGenerationTest.java | 59 +++++++++++++++++++ .../idgen/identity/joinedSubClass/Sub.java | 36 +++++++++++ .../idgen/identity/joinedSubClass/Super.java | 48 +++++++++++++++ 5 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/JoinedSubclassHierarchyWithIdentityGenerationTest.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Sub.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Super.java diff --git a/hibernate-core/src/main/java/org/hibernate/id/IdentityGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/IdentityGenerator.java index 0c90f1604e..57a60166ce 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/IdentityGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/IdentityGenerator.java @@ -99,7 +99,7 @@ public class IdentityGenerator extends AbstractPostInsertGenerator { rs = insert.getGeneratedKeys(); return IdentifierGeneratorHelper.getGeneratedIdentity( rs, - persister.getIdentifierColumnNames()[0], + persister.getRootTableKeyColumnNames()[0], persister.getIdentifierType() ); } @@ -150,7 +150,7 @@ public class IdentityGenerator extends AbstractPostInsertGenerator { try { return IdentifierGeneratorHelper.getGeneratedIdentity( rs, - persister.getIdentifierColumnNames()[0], + persister.getRootTableKeyColumnNames()[0], persister.getIdentifierType() ); } @@ -194,7 +194,7 @@ public class IdentityGenerator extends AbstractPostInsertGenerator { SessionImplementor session, ResultSet rs, Object object) throws SQLException { - return IdentifierGeneratorHelper.getGeneratedIdentity( rs, null, persister.getIdentifierType() ); + return IdentifierGeneratorHelper.getGeneratedIdentity( rs, persister.getRootTableKeyColumnNames()[0], persister.getIdentifierType() ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/id/SequenceIdentityGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/SequenceIdentityGenerator.java index c7e1427f3f..8aa4aa85da 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/SequenceIdentityGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/SequenceIdentityGenerator.java @@ -111,7 +111,7 @@ public class SequenceIdentityGenerator insert.executeUpdate(); return IdentifierGeneratorHelper.getGeneratedIdentity( insert.getGeneratedKeys(), - getPersister().getIdentifierColumnNames()[0], + getPersister().getRootTableKeyColumnNames()[0], getPersister().getIdentifierType() ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/JoinedSubclassHierarchyWithIdentityGenerationTest.java b/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/JoinedSubclassHierarchyWithIdentityGenerationTest.java new file mode 100644 index 0000000000..3f27d7f9b8 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/JoinedSubclassHierarchyWithIdentityGenerationTest.java @@ -0,0 +1,59 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.idgen.identity.joinedSubClass; + +import org.hibernate.Session; + +import org.junit.Test; + +import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.RequiresDialectFeature; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; + +/** + * @author Andrey Vlasov + * @author Steve Ebersole + */ +@RequiresDialectFeature( DialectChecks.SupportsIdentityColumns.class ) +public class JoinedSubclassHierarchyWithIdentityGenerationTest extends BaseCoreFunctionalTestCase { + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { Sub.class }; + } + + @Test + public void shouldPersistDebtorAccountWhenParentServiceAgreementPersisted() { + Session s = openSession(); + s.beginTransaction(); + s.save( new Sub() ); + s.getTransaction().commit(); + s.close(); + + s = openSession(); + s.beginTransaction(); + s.createQuery( "delete Sub" ).executeUpdate(); + s.getTransaction().commit(); + s.close(); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Sub.java b/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Sub.java new file mode 100644 index 0000000000..db6c9cfc13 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Sub.java @@ -0,0 +1,36 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.idgen.identity.joinedSubClass; + +import javax.persistence.Entity; +import javax.persistence.PrimaryKeyJoinColumn; + +/** + * @author Andrey Vlasov + * @author Steve Ebersole + */ +@Entity +@PrimaryKeyJoinColumn(name = "super_id") +public class Sub extends Super { +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Super.java b/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Super.java new file mode 100644 index 0000000000..41f320e828 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Super.java @@ -0,0 +1,48 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.idgen.identity.joinedSubClass; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; + +import static javax.persistence.GenerationType.IDENTITY; +import static javax.persistence.InheritanceType.JOINED; + +/** + * @author Andrey Vlasov + * @author Steve Ebersole + */ +@Entity +@Inheritance(strategy = JOINED) +public class Super { + @Id + @GeneratedValue(strategy = IDENTITY) + private Long id; + + @Column + private Long value; +} From 4e22fb9044e0664bce3d6a3bbe93a11248e7541e Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Tue, 4 Sep 2012 16:08:28 -0500 Subject: [PATCH 19/38] HHH-7566 - Activating JOIN fetch profile involving self-referential associations causes StackOverflowError --- .../loader/criteria/CriteriaJoinWalker.java | 10 ++- .../join/selfReferencing/Employee.java | 86 +++++++++++++++++++ .../JoinSelfReferentialFetchProfileTest.java | 53 ++++++++++++ 3 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/Employee.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/JoinSelfReferentialFetchProfileTest.java diff --git a/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java b/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java index 166a2a6f5d..1b009ce860 100755 --- a/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java @@ -155,7 +155,15 @@ public class CriteriaJoinWalker extends AbstractEntityJoinWalker { if ( isDefaultFetchMode( fetchMode ) ) { if ( persister != null ) { if ( isJoinFetchEnabledByProfile( persister, path, propertyNumber ) ) { - resolvedJoinType = getJoinType( nullable, currentDepth ); + if ( isDuplicateAssociation( lhsTable, lhsColumns, associationType ) ) { + resolvedJoinType = JoinType.NONE; + } + else if ( isTooDeep(currentDepth) || ( associationType.isCollectionType() && isTooManyCollections() ) ) { + resolvedJoinType = JoinType.NONE; + } + else { + resolvedJoinType = getJoinType( nullable, currentDepth ); + } } else { resolvedJoinType = super.getJoinType( diff --git a/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/Employee.java b/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/Employee.java new file mode 100644 index 0000000000..8fdf82ba2e --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/Employee.java @@ -0,0 +1,86 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.fetchprofiles.join.selfReferencing; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import java.util.ArrayList; +import java.util.Collection; + +import org.hibernate.annotations.FetchMode; +import org.hibernate.annotations.FetchProfile; +import org.hibernate.annotations.FetchProfiles; + +/** + * @author Steve Ebersole + */ +@Entity +@FetchProfiles( + @FetchProfile( + name = Employee.FETCH_PROFILE_TREE, + fetchOverrides = { + @FetchProfile.FetchOverride(entity = Employee.class, association = "manager", mode = FetchMode.JOIN), + @FetchProfile.FetchOverride(entity = Employee.class, association = "minions", mode = FetchMode.JOIN) + } + ) +) +public class Employee { + public final static String FETCH_PROFILE_TREE = "locationTree"; + + private Long id; + private Employee manager; + private Collection minions = new ArrayList(); + + @Id + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "manager_id") + public Employee getManager() { + return manager; + } + + public void setManager(Employee manager) { + this.manager = manager; + } + + @OneToMany(mappedBy = "manager", fetch = FetchType.LAZY) + public Collection getMinions() { + return minions; + } + + public void setMinions(Collection minions) { + this.minions = minions; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/JoinSelfReferentialFetchProfileTest.java b/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/JoinSelfReferentialFetchProfileTest.java new file mode 100644 index 0000000000..2cd272d41f --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/JoinSelfReferentialFetchProfileTest.java @@ -0,0 +1,53 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 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 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 + * 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.test.fetchprofiles.join.selfReferencing; + +import org.hibernate.Session; +import org.hibernate.criterion.Restrictions; + +import org.junit.Test; + +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; + +/** + * @author Steve Ebersole + */ +public class JoinSelfReferentialFetchProfileTest extends BaseCoreFunctionalTestCase { + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { Employee.class }; + } + + @Test + public void testEnablingJoinFetchProfileAgainstSelfReferentialAssociation() { + Session s = openSession(); + s.beginTransaction(); + s.enableFetchProfile( Employee.FETCH_PROFILE_TREE ); + s.createCriteria( Employee.class ) + .add( Restrictions.isNull( "manager" ) ) + .list(); + s.getTransaction().commit(); + s.close(); + } +} From e8b26952899426c2c3ead61cdd1ff3095c0dd134 Mon Sep 17 00:00:00 2001 From: Dustin Schultz Date: Fri, 24 Aug 2012 13:53:34 -0600 Subject: [PATCH 20/38] HHH-7544 Fixes java.lang.VerifyError by building StackMapTables at appropriate places. --- .../internal/JavassistInstrumenter.java | 19 ++++++++++ .../internal/javassist/FieldTransformer.java | 38 ++++++++++++------- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/buildtime/internal/JavassistInstrumenter.java b/hibernate-core/src/main/java/org/hibernate/bytecode/buildtime/internal/JavassistInstrumenter.java index 1182ed9d18..e3c4bd8513 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/buildtime/internal/JavassistInstrumenter.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/buildtime/internal/JavassistInstrumenter.java @@ -25,9 +25,13 @@ package org.hibernate.bytecode.buildtime.internal; import java.io.ByteArrayInputStream; import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.util.Set; +import javassist.ClassClassPath; +import javassist.ClassPool; import javassist.bytecode.ClassFile; import org.hibernate.bytecode.buildtime.spi.AbstractInstrumenter; @@ -44,6 +48,7 @@ import org.hibernate.bytecode.spi.ClassTransformer; * * @author Steve Ebersole * @author Muga Nishizawa + * @author Dustin Schultz */ public class JavassistInstrumenter extends AbstractInstrumenter { @@ -70,6 +75,20 @@ public class JavassistInstrumenter extends AbstractInstrumenter { return provider.getTransformer( CLASS_FILTER, new CustomFieldFilter( descriptor, classNames ) ); } } + + @Override + public void execute(Set files) { + ClassPool cp = ClassPool.getDefault(); + cp.insertClassPath(new ClassClassPath(this.getClass())); + try { + for (File file : files) { + cp.makeClass(new FileInputStream(file)); + } + } catch (IOException e) { + throw new RuntimeException(e.getMessage(), e); + } + super.execute(files); + } private static class CustomClassDescriptor implements ClassDescriptor { private final byte[] bytes; diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java index 4757612b80..300238fee4 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java @@ -32,6 +32,7 @@ import java.util.Iterator; import java.util.List; import javassist.CannotCompileException; +import javassist.ClassPool; import javassist.bytecode.AccessFlag; import javassist.bytecode.BadBytecode; import javassist.bytecode.Bytecode; @@ -43,6 +44,8 @@ import javassist.bytecode.Descriptor; import javassist.bytecode.FieldInfo; import javassist.bytecode.MethodInfo; import javassist.bytecode.Opcode; +import javassist.bytecode.StackMapTable; +import javassist.bytecode.stackmap.MapMaker; /** * The thing that handles actual class enhancement in regards to @@ -50,6 +53,7 @@ import javassist.bytecode.Opcode; * * @author Muga Nishizawa * @author Steve Ebersole + * @author Dustin Schultz */ public class FieldTransformer { @@ -130,7 +134,7 @@ public class FieldTransformer { } private void addGetFieldHandlerMethod(ClassFile classfile) - throws CannotCompileException { + throws CannotCompileException, BadBytecode { ConstPool cp = classfile.getConstPool(); int this_class_index = cp.getThisClassInfo(); MethodInfo minfo = new MethodInfo(cp, GETFIELDHANDLER_METHOD_NAME, @@ -148,11 +152,13 @@ public class FieldTransformer { code.addOpcode(Opcode.ARETURN); minfo.setCodeAttribute(code.toCodeAttribute()); minfo.setAccessFlags(AccessFlag.PUBLIC); + StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo); + minfo.getCodeAttribute().setAttribute(smt); classfile.addMethod(minfo); } private void addSetFieldHandlerMethod(ClassFile classfile) - throws CannotCompileException { + throws CannotCompileException, BadBytecode { ConstPool cp = classfile.getConstPool(); int this_class_index = cp.getThisClassInfo(); MethodInfo minfo = new MethodInfo(cp, SETFIELDHANDLER_METHOD_NAME, @@ -172,6 +178,8 @@ public class FieldTransformer { code.addOpcode(Opcode.RETURN); minfo.setCodeAttribute(code.toCodeAttribute()); minfo.setAccessFlags(AccessFlag.PUBLIC); + StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo); + minfo.getCodeAttribute().setAttribute(smt); classfile.addMethod(minfo); } @@ -185,7 +193,7 @@ public class FieldTransformer { } private void addReadWriteMethods(ClassFile classfile) - throws CannotCompileException { + throws CannotCompileException, BadBytecode { List fields = classfile.getFields(); for (Iterator field_iter = fields.iterator(); field_iter.hasNext();) { FieldInfo finfo = (FieldInfo) field_iter.next(); @@ -205,7 +213,7 @@ public class FieldTransformer { } private void addReadMethod(ClassFile classfile, FieldInfo finfo) - throws CannotCompileException { + throws CannotCompileException, BadBytecode { ConstPool cp = classfile.getConstPool(); int this_class_index = cp.getThisClassInfo(); String desc = "()" + finfo.getDescriptor(); @@ -254,11 +262,13 @@ public class FieldTransformer { minfo.setCodeAttribute(code.toCodeAttribute()); minfo.setAccessFlags(AccessFlag.PUBLIC); + StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo); + minfo.getCodeAttribute().setAttribute(smt); classfile.addMethod(minfo); } private void addWriteMethod(ClassFile classfile, FieldInfo finfo) - throws CannotCompileException { + throws CannotCompileException, BadBytecode { ConstPool cp = classfile.getConstPool(); int this_class_index = cp.getThisClassInfo(); String desc = "(" + finfo.getDescriptor() + ")V"; @@ -320,11 +330,13 @@ public class FieldTransformer { minfo.setCodeAttribute(code.toCodeAttribute()); minfo.setAccessFlags(AccessFlag.PUBLIC); + StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo); + minfo.getCodeAttribute().setAttribute(smt); classfile.addMethod(minfo); } private void transformInvokevirtualsIntoPutAndGetfields(ClassFile classfile) - throws CannotCompileException { + throws CannotCompileException, BadBytecode { List methods = classfile.getMethods(); for (Iterator method_iter = methods.iterator(); method_iter.hasNext();) { MethodInfo minfo = (MethodInfo) method_iter.next(); @@ -341,15 +353,13 @@ public class FieldTransformer { } CodeIterator iter = codeAttr.iterator(); while (iter.hasNext()) { - try { - int pos = iter.next(); - pos = transformInvokevirtualsIntoGetfields(classfile, iter, pos); - pos = transformInvokevirtualsIntoPutfields(classfile, iter, pos); - - } catch (BadBytecode e) { - throw new CannotCompileException(e); - } + int pos = iter.next(); + pos = transformInvokevirtualsIntoGetfields(classfile, iter, pos); + pos = transformInvokevirtualsIntoPutfields(classfile, iter, pos); } + + StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo); + minfo.getCodeAttribute().setAttribute(smt); } } From 072e64d26ac2e957a07792b3a89595bd206c9593 Mon Sep 17 00:00:00 2001 From: nrodrigues Date: Sat, 18 Aug 2012 17:27:12 +0100 Subject: [PATCH 21/38] HHH-7532 - Override getForUpdateString with correct syntax --- .../src/main/java/org/hibernate/dialect/DB2400Dialect.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DB2400Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DB2400Dialect.java index 67633c2c5c..4f93f7af25 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DB2400Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DB2400Dialect.java @@ -71,4 +71,7 @@ public class DB2400Dialect extends DB2Dialect { .toString(); } + public String getForUpdateString() { + return " for update with rs"; + } } \ No newline at end of file From 401d4902fd8e020d8af16cfae7b36b644ac08aa3 Mon Sep 17 00:00:00 2001 From: "U-MateusPimenta\\Mateus Pimenta" Date: Fri, 10 Aug 2012 01:37:49 -0300 Subject: [PATCH 22/38] HHH-7518 --- .../management/impl/ProviderMBeanRegistrationHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java index f8a78ba138..10a4c28caf 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java @@ -149,7 +149,7 @@ public class ProviderMBeanRegistrationHelper { throw new RuntimeException( "Expected 'sessionFactoryMap' field on " + SessionFactoryRegistry.class.getName() ); } instancesField.setAccessible( true ); - Map map = (Map) instancesField.get( null ); + Map map = (Map) instancesField.get( SessionFactoryRegistry.INSTANCE ); if ( map == null ) { return null; } From a043701de75f78e6735cc08340939283b8077f57 Mon Sep 17 00:00:00 2001 From: Guenther Demetz Date: Thu, 3 May 2012 14:00:01 +0200 Subject: [PATCH 23/38] HHH-7059 The DerbyDialect deprecation warning should appear no more, when using one of the version-specific dialects --- .../src/main/java/org/hibernate/dialect/DerbyDialect.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java index de7950843f..deab2055b5 100755 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java @@ -56,7 +56,9 @@ public class DerbyDialect extends DB2Dialect { public DerbyDialect() { super(); - LOG.deprecatedDerbyDialect(); + if (this.getClass() == DerbyDialect.class) { + LOG.deprecatedDerbyDialect(); + } registerFunction( "concat", new DerbyConcatFunction() ); registerFunction( "trim", new AnsiTrimFunction() ); registerColumnType( Types.BLOB, "blob" ); From e9d00d4b35cd05c6d94868182ea1c81817cecdcb Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Wed, 5 Sep 2012 14:46:02 +0800 Subject: [PATCH 24/38] Merge branches 'pb00067-patch-8' and 'master' From 8fa530a24773dce3d73c4dce588a057eebf74136 Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Wed, 5 Sep 2012 17:06:40 +0800 Subject: [PATCH 25/38] HHH-7300 - TypeDefs won't be found depending of files read-order --- .../java/org/hibernate/cfg/HbmBinder.java | 42 +++++++ .../test/mapping/usertypes/EnumUserType.java | 116 ++++++++++++++++++ .../test/mapping/usertypes/TestEntity.hbm.xml | 13 ++ .../test/mapping/usertypes/TestEntity.java | 19 +++ .../test/mapping/usertypes/TestEnum.java | 6 + .../mapping/usertypes/TestEnumType.hbm.xml | 8 ++ .../usertypes/UserTypeMappingTest.java | 58 +++++++++ 7 files changed, 262 insertions(+) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/EnumUserType.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml create mode 100644 hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnum.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml create mode 100644 hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/UserTypeMappingTest.java diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java index aed5cff60d..6692db88f7 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java @@ -96,6 +96,7 @@ import org.hibernate.mapping.TypeDef; import org.hibernate.mapping.UnionSubclass; import org.hibernate.mapping.UniqueKey; import org.hibernate.mapping.Value; +import org.hibernate.type.BasicType; import org.hibernate.type.DiscriminatorType; import org.hibernate.type.ForeignKeyDirection; import org.hibernate.type.Type; @@ -1213,6 +1214,11 @@ public final class HbmBinder { } } + resolveAndBindTypeDef(simpleValue, mappings, typeName, parameters); + } + + private static void resolveAndBindTypeDef(SimpleValue simpleValue, + Mappings mappings, String typeName, Properties parameters) { TypeDef typeDef = mappings.getTypeDef( typeName ); if ( typeDef != null ) { typeName = typeDef.getTypeClass(); @@ -1222,6 +1228,19 @@ public final class HbmBinder { allParameters.putAll( typeDef.getParameters() ); allParameters.putAll( parameters ); parameters = allParameters; + }else if (typeName!=null && !mappings.isInSecondPass()){ + BasicType basicType=mappings.getTypeResolver().basic(typeName); + if (basicType==null) { + /* + * If the referenced typeName isn't a basic-type, it's probably a typedef defined + * in a mapping file not read yet. + * It should be solved by deferring the resolution and binding of this type until + * all mapping files are read - the second passes. + * Fixes issue HHH-7300 + */ + SecondPass resolveUserTypeMappingSecondPass=new ResolveUserTypeMappingSecondPass(simpleValue,typeName,mappings,parameters); + mappings.addSecondPass(resolveUserTypeMappingSecondPass); + } } if ( !parameters.isEmpty() ) simpleValue.setTypeParameters( parameters ); @@ -3149,4 +3168,27 @@ public final class HbmBinder { private static interface EntityElementHandler { public void handleEntity(String entityName, String className, Mappings mappings); } + + private static class ResolveUserTypeMappingSecondPass implements SecondPass{ + + private SimpleValue simpleValue; + private String typeName; + private Mappings mappings; + private Properties parameters; + + public ResolveUserTypeMappingSecondPass(SimpleValue simpleValue, + String typeName, Mappings mappings, Properties parameters) { + this.simpleValue=simpleValue; + this.typeName=typeName; + this.parameters=parameters; + this.mappings=mappings; + } + + @Override + public void doSecondPass(java.util.Map persistentClasses) + throws MappingException { + resolveAndBindTypeDef(simpleValue, mappings, typeName, parameters); + } + + } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/EnumUserType.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/EnumUserType.java new file mode 100644 index 0000000000..ff95a7b2f6 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/EnumUserType.java @@ -0,0 +1,116 @@ +package org.hibernate.test.mapping.usertypes; +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.Properties; + +import org.hibernate.HibernateException; +import org.hibernate.MappingException; +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.usertype.ParameterizedType; +import org.hibernate.usertype.UserType; + +public class EnumUserType implements UserType, ParameterizedType { + + private Class clazz = null; + + public static EnumUserType createInstance(Class clazz){ + if (!clazz.isEnum()) + throw new IllegalArgumentException("Parameter has to be an enum-class"); + EnumUserType that=new EnumUserType(); + Properties p=new Properties(); + p.setProperty("enumClassName", clazz.getName()); + that.setParameterValues(p); + return that; + } + + public void setParameterValues(Properties params) { + String enumClassName = params.getProperty("enumClassName"); + if (enumClassName == null) { + throw new MappingException("enumClassName parameter not specified"); + } + + try { + this.clazz = Class.forName(enumClassName); + } catch (ClassNotFoundException e) { + throw new MappingException("enumClass " + enumClassName + " not found", e); + } + if (!this.clazz.isEnum()){ + throw new MappingException("enumClass "+enumClassName+" doesn't refer to an Enum"); + } + } + + private static final int[] SQL_TYPES = {Types.CHAR}; + public int[] sqlTypes() { + return SQL_TYPES; + } + + public Class returnedClass() { + return clazz; + } + + public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) + throws HibernateException, SQLException { + String name = resultSet.getString(names[0]); + Object result = null; + if (!resultSet.wasNull()) { + result = Enum.valueOf(clazz, name.trim()); + } + return result; + } + + @Override + public Object nullSafeGet(ResultSet resultSet, String[] names, + SessionImplementor session, Object owner) throws HibernateException, + SQLException { + return nullSafeGet(resultSet, names, owner); + } + +public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) + throws HibernateException, SQLException { + if (null == value) { + preparedStatement.setNull(index, Types.VARCHAR); + } else { + preparedStatement.setString(index, ((Enum)value).name()); + } + } + + @Override +public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index, + SessionImplementor session) throws HibernateException, SQLException { + nullSafeSet(preparedStatement, value, index); +} + + public Object deepCopy(Object value) throws HibernateException{ + return value; + } + + public boolean isMutable() { + return false; + } + + public Object assemble(Serializable cached, Object owner) throws HibernateException { + return cached; + } + + public Serializable disassemble(Object value) throws HibernateException { + return (Serializable)value; + } + + public Object replace(Object original, Object target, Object owner) throws HibernateException { + return original; + } + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); + } + public boolean equals(Object x, Object y) throws HibernateException { + if (x == y) + return true; + if (null == x || null == y) + return false; + return x.equals(y); + } +} + diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml new file mode 100644 index 0000000000..df6ed68b30 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.java new file mode 100644 index 0000000000..79ed360bd5 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.java @@ -0,0 +1,19 @@ +package org.hibernate.test.mapping.usertypes; + +public class TestEntity { + private int id; + private TestEnum testEnum; + + public void setId(int id) { + this.id = id; + } + public int getId() { + return id; + } + public void setTestEnum(TestEnum testEnum) { + this.testEnum = testEnum; + } + public TestEnum getTestEnum() { + return testEnum; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnum.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnum.java new file mode 100644 index 0000000000..8aab6b72ba --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnum.java @@ -0,0 +1,6 @@ +package org.hibernate.test.mapping.usertypes; + +public enum TestEnum { + FOO, + BAR; +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml new file mode 100644 index 0000000000..20acceaae2 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml @@ -0,0 +1,8 @@ + + + + + + org.hibernate.test.mapping.usertypes.TestEnum + + diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/UserTypeMappingTest.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/UserTypeMappingTest.java new file mode 100644 index 0000000000..dcd4cbc133 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/UserTypeMappingTest.java @@ -0,0 +1,58 @@ +package org.hibernate.test.mapping.usertypes; + + +import java.util.Properties; + +import org.hibernate.SessionFactory; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; +import org.hibernate.service.ServiceRegistry; +import org.hibernate.testing.ServiceRegistryBuilder; +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.junit4.BaseUnitTestCase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Test for read-order independent resolution of user-defined types + * Testcase for issue HHH-7300 + * @author Stefan Schulze + */ +@TestForIssue(jiraKey = "HHH-7300") +public class UserTypeMappingTest extends BaseUnitTestCase{ + +private Configuration cfg; +private ServiceRegistry serviceRegistry; + + @Before + public void setup(){ + cfg=new Configuration(); + Properties p = new Properties(); + p.put( Environment.DIALECT, "org.hibernate.dialect.HSQLDialect" ); + p.put( "hibernate.connection.driver_class", "org.h2.Driver" ); + p.put( "hibernate.connection.url", "jdbc:h2:mem:" ); + p.put( "hibernate.connection.username", "sa" ); + p.put( "hibernate.connection.password", "" ); + cfg.setProperties(p); + serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ); + } + + @Test + public void testFirstTypeThenEntity(){ + cfg.addResource("org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml") + .addResource("org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml"); + SessionFactory sessions=cfg.buildSessionFactory(serviceRegistry); + Assert.assertNotNull(sessions); + } + + @Test + public void testFirstEntityThenType(){ + cfg.addResource("org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml") + .addResource("org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml"); + + SessionFactory sessions=cfg.buildSessionFactory(serviceRegistry); + Assert.assertNotNull(sessions); + } + +} From 4fe75d5a093902937c8247c6427566bdca474951 Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Wed, 5 Sep 2012 17:21:36 +0800 Subject: [PATCH 26/38] HHH-7371 Natural-id: ObjectNotFoundException when found entity is marked as deleted --- .../org/hibernate/internal/SessionImpl.java | 25 ++++++++++- .../ImmutableEntityNaturalIdTest.java | 42 +++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index 52824ed5e0..38df7cbda9 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -45,6 +45,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import javax.persistence.EntityNotFoundException; + import org.jboss.logging.Logger; import org.hibernate.AssertionFailure; @@ -64,6 +66,7 @@ import org.hibernate.LockOptions; import org.hibernate.MappingException; import org.hibernate.NaturalIdLoadAccess; import org.hibernate.ObjectDeletedException; +import org.hibernate.ObjectNotFoundException; import org.hibernate.Query; import org.hibernate.QueryException; import org.hibernate.ReplicationMode; @@ -2605,7 +2608,16 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc if ( entityId == null ) { return null; } - return this.getIdentifierLoadAccess().load( entityId ); + try { + return this.getIdentifierLoadAccess().load( entityId ); + } + catch (EntityNotFoundException enf) { + // OK + } + catch (ObjectNotFoundException nf) { + // OK + } + return null; } } @@ -2663,7 +2675,16 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc if ( entityId == null ) { return null; } - return this.getIdentifierLoadAccess().load( entityId ); + try { + return this.getIdentifierLoadAccess().load( entityId ); + } + catch (EntityNotFoundException enf) { + // OK + } + catch (ObjectNotFoundException nf) { + // OK + } + return null; } } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/naturalid/immutableentity/ImmutableEntityNaturalIdTest.java b/hibernate-core/src/test/java/org/hibernate/test/naturalid/immutableentity/ImmutableEntityNaturalIdTest.java index cc79c28a3b..b103046511 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/naturalid/immutableentity/ImmutableEntityNaturalIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/naturalid/immutableentity/ImmutableEntityNaturalIdTest.java @@ -160,6 +160,48 @@ public class ImmutableEntityNaturalIdTest extends BaseCoreFunctionalTestCase { tx.rollback(); s.close(); } + + @Test + @TestForIssue( jiraKey = "HHH-7371" ) + public void testImmutableNaturalIdLifecycle2() { + Building b1 = new Building(); + b1.setName( "Computer Science" ); + b1.setAddress( "1210 W. Dayton St." ); + b1.setCity( "Madison" ); + b1.setState( "WI" ); + + Session s = openSession(); + Transaction tx = s.beginTransaction(); + s.persist( b1 ); + tx.commit(); + s.close(); + + + s = openSession(); + tx = s.beginTransaction(); + NaturalIdLoadAccess naturalIdLoader = s.byNaturalId( Building.class ); + naturalIdLoader.using( "address", "1210 W. Dayton St." ).using( "city", "Madison" ).using( "state", "WI" ); + Building building = (Building) naturalIdLoader.getReference(); + assertNotNull( building ); + + s.delete( building ); + building = (Building) naturalIdLoader.load(); + //org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.hibernate.test.naturalid.immutableentity.Building#1] +// at org.hibernate.internal.SessionFactoryImpl$1$1.handleEntityNotFound(SessionFactoryImpl.java:247) +// at org.hibernate.event.internal.DefaultLoadEventListener.returnNarrowedProxy(DefaultLoadEventListener.java:282) +// at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:248) +// at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:148) +// at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1079) +// at org.hibernate.internal.SessionImpl.access$13(SessionImpl.java:1075) +// at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2425) +// at org.hibernate.internal.SessionImpl$NaturalIdLoadAccessImpl.load(SessionImpl.java:2586) +// at org.hibernate.test.naturalid.immutableentity.ImmutableEntityNaturalIdTest.testImmutableNaturalIdLifecycle2(ImmutableEntityNaturalIdTest.java:188) + + assertNull( building ); + + tx.commit(); + s.close(); + } @Override protected Class[] getAnnotatedClasses() { From 6ac746fffce8cf920c70b20ce4a239d79ec0c08d Mon Sep 17 00:00:00 2001 From: Shawn Clowater Date: Tue, 8 May 2012 15:54:05 -0600 Subject: [PATCH 27/38] HHH-7308 Change the beforeCompletion() method of the TransactionObserver() to call the beforeTransactionCompletion() method regardless of whether or not the session is open like the afterCompletion() method does when calling the afterTransactionCompletion() and also cleaned up the log message around session having after transaction events as this sort of logging had been previously moved to the close() method of SessionImpl. --- .../java/org/hibernate/internal/SessionImpl.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index 38df7cbda9..03de22b3a1 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -285,17 +285,10 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc @Override public void beforeCompletion(TransactionImplementor transaction) { - if ( isOpen() ) { - if ( flushBeforeCompletionEnabled ){ - SessionImpl.this.managedFlush(); - } - getActionQueue().beforeTransactionCompletion(); - } - else { - if (actionQueue.hasAfterTransactionActions()){ - LOG.log( Logger.Level.DEBUG, "Session had after transaction actions that were not processed"); - } + if ( isOpen() && flushBeforeCompletionEnabled ) { + SessionImpl.this.managedFlush(); } + beforeTransactionCompletion( transaction ); } @Override From 970bd8679e8e019a16e005d8db29c5c3681031fb Mon Sep 17 00:00:00 2001 From: brmeyer Date: Tue, 4 Sep 2012 18:41:51 -0400 Subject: [PATCH 28/38] HHH-1123 Cannot put more than 1000 elements in a InExpression --- .../java/org/hibernate/dialect/Dialect.java | 20 +++++++++++++ .../hibernate/dialect/Oracle8iDialect.java | 21 ++++++++++++-- .../org/hibernate/dialect/Oracle9Dialect.java | 21 ++++++++++++-- .../hibernate/dialect/SQLServerDialect.java | 18 ++++++++++++ .../hibernate/dialect/Sybase11Dialect.java | 2 +- .../hibernate/dialect/SybaseASE15Dialect.java | 2 +- .../dialect/SybaseAnywhereDialect.java | 2 +- .../org/hibernate/dialect/SybaseDialect.java | 29 +++++++++++++------ .../hibernate/dialect/TeradataDialect.java | 18 ++++++++++++ .../hibernate/internal/AbstractQueryImpl.java | 19 ++++++++++++ .../test/criteria/LongInElementsTest.java | 12 ++++---- 11 files changed, 141 insertions(+), 23 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java index 8ccf2219b2..c592070cc9 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -2365,4 +2365,24 @@ public abstract class Dialect implements ConversionContext { // oddly most database in fact seem to, so true is the default. return true; } + + /** + * Does this databases restrict the number of parameters in a query list? + * + * @return boolean + * True if limited, false if not. + */ + public boolean limitsParamListSize() { + return false; + } + + /** + * If limitsListSize() is true, define the size threshold. + * + * @return int + * The list size threshold + */ + public int getParamListSizeLimit() { + return 0; + } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java index d2d33db4bc..b15fc58012 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java @@ -58,6 +58,8 @@ import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; * @author Steve Ebersole */ public class Oracle8iDialect extends Dialect { + + private static final int PARAM_LIST_SIZE_LIMIT = 1000; public Oracle8iDialect() { super(); @@ -551,15 +553,30 @@ public class Oracle8iDialect extends Dialect { return false; } - - // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @Override public boolean supportsEmptyInList() { return false; } + @Override public boolean supportsExistsInSelect() { return false; } + + /* (non-Javadoc) + * @see org.hibernate.dialect.Dialect#limitsParamListSize() + */ + @Override + public boolean limitsParamListSize() { + return true; + } + + /* (non-Javadoc) + * @see org.hibernate.dialect.Dialect#getParamListSizeLimit() + */ + @Override + public int getParamListSizeLimit() { + return PARAM_LIST_SIZE_LIMIT; + } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java index b502e9c8e8..88272f470e 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java @@ -52,6 +52,8 @@ import org.hibernate.type.StandardBasicTypes; */ @Deprecated public class Oracle9Dialect extends Dialect { + + private static final int PARAM_LIST_SIZE_LIMIT = 1000; private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, Oracle9Dialect.class.getName()); @@ -360,9 +362,6 @@ public class Oracle9Dialect extends Dialect { return false; } - - // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - public boolean supportsEmptyInList() { return false; } @@ -370,4 +369,20 @@ public class Oracle9Dialect extends Dialect { public boolean supportsExistsInSelect() { return false; } + + /* (non-Javadoc) + * @see org.hibernate.dialect.Dialect#limitsParamListSize() + */ + @Override + public boolean limitsParamListSize() { + return true; + } + + /* (non-Javadoc) + * @see org.hibernate.dialect.Dialect#getParamListSizeLimit() + */ + @Override + public int getParamListSizeLimit() { + return PARAM_LIST_SIZE_LIMIT; + } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java index 62b91492b9..bdbffa92aa 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java @@ -39,6 +39,8 @@ import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; * @author Gavin King */ public class SQLServerDialect extends AbstractTransactSQLDialect { + + private static final int PARAM_LIST_SIZE_LIMIT = 2100; public SQLServerDialect() { registerColumnType( Types.VARBINARY, "image" ); @@ -188,5 +190,21 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { protected SqlTypeDescriptor getSqlTypeDescriptorOverride( int sqlCode ) { return sqlCode == Types.TINYINT ? SmallIntTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride(sqlCode); } + + /* (non-Javadoc) + * @see org.hibernate.dialect.Dialect#limitsParamListSize() + */ + @Override + public boolean limitsParamListSize() { + return true; + } + + /* (non-Javadoc) + * @see org.hibernate.dialect.Dialect#getParamListSizeLimit() + */ + @Override + public int getParamListSizeLimit() { + return PARAM_LIST_SIZE_LIMIT; + } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java index 42dbbaf949..bb94974c5a 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java @@ -29,7 +29,7 @@ import org.hibernate.sql.Sybase11JoinFragment; * A SQL dialect suitable for use with Sybase 11.9.2 (specifically: avoids ANSI JOIN syntax) * @author Colm O' Flaherty */ -public class Sybase11Dialect extends AbstractTransactSQLDialect { +public class Sybase11Dialect extends SybaseDialect { public Sybase11Dialect() { super(); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java index 0836f4f394..423ced7cb7 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java @@ -40,7 +40,7 @@ import org.hibernate.type.descriptor.sql.TinyIntTypeDescriptor; * * @author Gavin King */ -public class SybaseASE15Dialect extends AbstractTransactSQLDialect { +public class SybaseASE15Dialect extends SybaseDialect { public SybaseASE15Dialect() { super(); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java index a10a7da155..688c917c06 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java @@ -30,7 +30,7 @@ package org.hibernate.dialect; * (Tested on ASA 8.x) * @author ? */ -public class SybaseAnywhereDialect extends AbstractTransactSQLDialect { +public class SybaseAnywhereDialect extends SybaseDialect { /** * Sybase Anywhere syntax would require a "DEFAULT" for each column specified, * but I suppose Hibernate use this syntax only with tables with just 1 column diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java index a651f59d5e..13ed3bc876 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java @@ -25,16 +25,27 @@ package org.hibernate.dialect; /** - * This dialect is being deprecated; it had been used both as the base class - * for TransactSQL-based dialects as well as the physical dialect for handling - * Sybase. Those functions have now been split. - * {@link AbstractTransactSQLDialect} should be used as the base class for - * TransactSQL-based dialects. + * All Sybase dialects share an IN list size limit. * - * @deprecated use {@link AbstractTransactSQLDialect}, {@link SybaseASE15Dialect} or {@link SQLServerDialect} - * instead depending on need. - * - * @author Gail Badner + * @author Brett Meyer */ public class SybaseDialect extends AbstractTransactSQLDialect { + + private static final int PARAM_LIST_SIZE_LIMIT = 250000; + + /* (non-Javadoc) + * @see org.hibernate.dialect.Dialect#limitsParamListSize() + */ + @Override + public boolean limitsParamListSize() { + return true; + } + + /* (non-Javadoc) + * @see org.hibernate.dialect.Dialect#getParamListSizeLimit() + */ + @Override + public int getParamListSizeLimit() { + return PARAM_LIST_SIZE_LIMIT; + } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java index e28a5a61ac..1f61120979 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java @@ -37,6 +37,8 @@ import org.hibernate.type.StandardBasicTypes; * @author Jay Nance */ public class TeradataDialect extends Dialect { + + private static final int PARAM_LIST_SIZE_LIMIT = 1024; /** * Constructor @@ -256,4 +258,20 @@ public class TeradataDialect extends Dialect { public boolean supportsBindAsCallableArgument() { return false; } + + /* (non-Javadoc) + * @see org.hibernate.dialect.Dialect#limitsParamListSize() + */ + @Override + public boolean limitsParamListSize() { + return true; + } + + /* (non-Javadoc) + * @see org.hibernate.dialect.Dialect#getParamListSizeLimit() + */ + @Override + public int getParamListSizeLimit() { + return PARAM_LIST_SIZE_LIMIT; + } } \ No newline at end of file diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractQueryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractQueryImpl.java index 432adf922d..fb130fa74c 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractQueryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractQueryImpl.java @@ -49,6 +49,7 @@ import org.hibernate.PropertyNotFoundException; import org.hibernate.Query; import org.hibernate.QueryException; import org.hibernate.Session; +import org.hibernate.dialect.Dialect; import org.hibernate.engine.query.spi.ParameterMetadata; import org.hibernate.engine.spi.QueryParameters; import org.hibernate.engine.spi.RowSelection; @@ -65,6 +66,7 @@ import org.hibernate.transform.ResultTransformer; import org.hibernate.type.SerializableType; import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.Type; +import org.jboss.logging.Logger; /** * Abstract implementation of the Query interface. @@ -73,6 +75,7 @@ import org.hibernate.type.Type; * @author Max Andersen */ public abstract class AbstractQueryImpl implements Query { + private static final Logger log = Logger.getLogger( AbstractQueryImpl.class ); private static final Object UNSET_PARAMETER = new MarkerObject(""); private static final Object UNSET_TYPE = new MarkerObject(""); @@ -798,6 +801,22 @@ public abstract class AbstractQueryImpl implements Query { */ private String expandParameterList(String query, String name, TypedValue typedList, Map namedParamsCopy) { Collection vals = (Collection) typedList.getValue(); + + // HHH-1123 + // Some DBs limit the size of param lists. For now, warn... + // + // TODO: HHH-1123 was rejected, but this issue may still deserve some + // research. + Dialect dialect = session.getFactory().getDialect(); + if (dialect.limitsParamListSize() + && vals.size() >= dialect.getParamListSizeLimit()) { + log.warn(dialect.getClass().getName() + + " limits the size of parameter lists to " + + dialect.getParamListSizeLimit() + + " entries. The given list size of " + + vals.size() + " may cause failures."); + } + Type type = typedList.getType(); boolean isJpaPositionalParam = parameterMetadata.getNamedParameterDescriptor( name ).isJpaStyle(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/criteria/LongInElementsTest.java b/hibernate-core/src/test/java/org/hibernate/test/criteria/LongInElementsTest.java index e7f7c6ddda..90a5ac3353 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/criteria/LongInElementsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/criteria/LongInElementsTest.java @@ -22,11 +22,11 @@ * Boston, MA 02110-1301 USA */ package org.hibernate.test.criteria; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.List; -import org.junit.Test; - import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.Session; @@ -34,13 +34,13 @@ import org.hibernate.Transaction; import org.hibernate.criterion.Restrictions; import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.dialect.SQLServerDialect; +import org.hibernate.dialect.SybaseDialect; import org.hibernate.dialect.TeradataDialect; import org.hibernate.test.hql.StateProvince; import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; +import org.junit.Test; /** * HHH-2166 Long "in" lists in queries results in a Java stack overflow @@ -60,7 +60,7 @@ public class LongInElementsTest extends BaseCoreFunctionalTestCase { @Test @TestForIssue( jiraKey = "HHH-2166" ) @SkipForDialect( - value = { SQLServerDialect.class, Oracle8iDialect.class, TeradataDialect.class }, + value = { SQLServerDialect.class, Oracle8iDialect.class, TeradataDialect.class, SybaseDialect.class }, comment = "this test fails on oracle and ms sql server, for more info, see HHH-1123" ) public void testLongInElementsByHQL() { @@ -90,7 +90,7 @@ public class LongInElementsTest extends BaseCoreFunctionalTestCase { @Test @TestForIssue( jiraKey = "HHH-2166" ) @SkipForDialect( - value = { SQLServerDialect.class, Oracle8iDialect.class, TeradataDialect.class }, + value = { SQLServerDialect.class, Oracle8iDialect.class, TeradataDialect.class, SybaseDialect.class }, comment = "this test fails on oracle and ms sql server, for more info, see HHH-1123" ) public void testLongInElementsByCriteria() { From 40574b9d8ae064cf051e62bc0c96ae9e328ffb93 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 5 Sep 2012 11:28:13 -0500 Subject: [PATCH 29/38] HHH-1123 - Cannot put more than 1000 elements in a InExpression --- .../java/org/hibernate/dialect/Dialect.java | 20 ++++------------ .../hibernate/dialect/Oracle8iDialect.java | 16 ++++--------- .../org/hibernate/dialect/Oracle9Dialect.java | 16 ++++--------- .../hibernate/dialect/SQLServerDialect.java | 16 ++++--------- .../org/hibernate/dialect/SybaseDialect.java | 16 ++++--------- .../hibernate/dialect/TeradataDialect.java | 16 ++++--------- .../hibernate/internal/AbstractQueryImpl.java | 24 ++++++++----------- .../hibernate/internal/CoreMessageLogger.java | 9 +++++++ .../test/criteria/LongInElementsTest.java | 2 +- 9 files changed, 45 insertions(+), 90 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java index c592070cc9..55e4cce9e0 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -2365,24 +2365,14 @@ public abstract class Dialect implements ConversionContext { // oddly most database in fact seem to, so true is the default. return true; } - + /** - * Does this databases restrict the number of parameters in a query list? + * Return the limit that the underlying database places on the number elements in an {@code IN} predicate. + * If the database defines no such limits, simply return zero or less-than-zero. * - * @return boolean - * True if limited, false if not. + * @return int The limit, or zero-or-less to indicate no limit. */ - public boolean limitsParamListSize() { - return false; - } - - /** - * If limitsListSize() is true, define the size threshold. - * - * @return int - * The list size threshold - */ - public int getParamListSizeLimit() { + public int getInExpressionCountLimit() { return 0; } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java index b15fc58012..40a5891f43 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java @@ -562,20 +562,12 @@ public class Oracle8iDialect extends Dialect { public boolean supportsExistsInSelect() { return false; } - + /* (non-Javadoc) - * @see org.hibernate.dialect.Dialect#limitsParamListSize() - */ + * @see org.hibernate.dialect.Dialect#getInExpressionCountLimit() + */ @Override - public boolean limitsParamListSize() { - return true; - } - - /* (non-Javadoc) - * @see org.hibernate.dialect.Dialect#getParamListSizeLimit() - */ - @Override - public int getParamListSizeLimit() { + public int getInExpressionCountLimit() { return PARAM_LIST_SIZE_LIMIT; } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java index 88272f470e..d0f0d8ce79 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java @@ -369,20 +369,12 @@ public class Oracle9Dialect extends Dialect { public boolean supportsExistsInSelect() { return false; } - + /* (non-Javadoc) - * @see org.hibernate.dialect.Dialect#limitsParamListSize() - */ + * @see org.hibernate.dialect.Dialect#getInExpressionCountLimit() + */ @Override - public boolean limitsParamListSize() { - return true; - } - - /* (non-Javadoc) - * @see org.hibernate.dialect.Dialect#getParamListSizeLimit() - */ - @Override - public int getParamListSizeLimit() { + public int getInExpressionCountLimit() { return PARAM_LIST_SIZE_LIMIT; } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java index bdbffa92aa..90a9e4b829 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java @@ -190,20 +190,12 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { protected SqlTypeDescriptor getSqlTypeDescriptorOverride( int sqlCode ) { return sqlCode == Types.TINYINT ? SmallIntTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride(sqlCode); } - + /* (non-Javadoc) - * @see org.hibernate.dialect.Dialect#limitsParamListSize() - */ + * @see org.hibernate.dialect.Dialect#getInExpressionCountLimit() + */ @Override - public boolean limitsParamListSize() { - return true; - } - - /* (non-Javadoc) - * @see org.hibernate.dialect.Dialect#getParamListSizeLimit() - */ - @Override - public int getParamListSizeLimit() { + public int getInExpressionCountLimit() { return PARAM_LIST_SIZE_LIMIT; } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java index 13ed3bc876..13f333933c 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java @@ -32,20 +32,12 @@ package org.hibernate.dialect; public class SybaseDialect extends AbstractTransactSQLDialect { private static final int PARAM_LIST_SIZE_LIMIT = 250000; - + /* (non-Javadoc) - * @see org.hibernate.dialect.Dialect#limitsParamListSize() - */ + * @see org.hibernate.dialect.Dialect#getInExpressionCountLimit() + */ @Override - public boolean limitsParamListSize() { - return true; - } - - /* (non-Javadoc) - * @see org.hibernate.dialect.Dialect#getParamListSizeLimit() - */ - @Override - public int getParamListSizeLimit() { + public int getInExpressionCountLimit() { return PARAM_LIST_SIZE_LIMIT; } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java index 1f61120979..942057aa64 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java @@ -258,20 +258,12 @@ public class TeradataDialect extends Dialect { public boolean supportsBindAsCallableArgument() { return false; } - + /* (non-Javadoc) - * @see org.hibernate.dialect.Dialect#limitsParamListSize() - */ + * @see org.hibernate.dialect.Dialect#getInExpressionCountLimit() + */ @Override - public boolean limitsParamListSize() { - return true; - } - - /* (non-Javadoc) - * @see org.hibernate.dialect.Dialect#getParamListSizeLimit() - */ - @Override - public int getParamListSizeLimit() { + public int getInExpressionCountLimit() { return PARAM_LIST_SIZE_LIMIT; } } \ No newline at end of file diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractQueryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractQueryImpl.java index fb130fa74c..3aa6b0d166 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractQueryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractQueryImpl.java @@ -75,7 +75,10 @@ import org.jboss.logging.Logger; * @author Max Andersen */ public abstract class AbstractQueryImpl implements Query { - private static final Logger log = Logger.getLogger( AbstractQueryImpl.class ); + private static final CoreMessageLogger log = Logger.getMessageLogger( + CoreMessageLogger.class, + AbstractQueryImpl.class.getName() + ); private static final Object UNSET_PARAMETER = new MarkerObject(""); private static final Object UNSET_TYPE = new MarkerObject(""); @@ -803,20 +806,13 @@ public abstract class AbstractQueryImpl implements Query { Collection vals = (Collection) typedList.getValue(); // HHH-1123 - // Some DBs limit the size of param lists. For now, warn... - // - // TODO: HHH-1123 was rejected, but this issue may still deserve some - // research. - Dialect dialect = session.getFactory().getDialect(); - if (dialect.limitsParamListSize() - && vals.size() >= dialect.getParamListSizeLimit()) { - log.warn(dialect.getClass().getName() - + " limits the size of parameter lists to " - + dialect.getParamListSizeLimit() - + " entries. The given list size of " - + vals.size() + " may cause failures."); + // Some DBs limit number of IN expressions. For now, warn... + final Dialect dialect = session.getFactory().getDialect(); + final int inExprLimit = dialect.getInExpressionCountLimit(); + if ( inExprLimit > 0 && vals.size() > inExprLimit ) { + log.tooManyInExpressions( dialect.getClass().getName(), inExprLimit, name, vals.size() ); } - + Type type = typedList.getType(); boolean isJpaPositionalParam = parameterMetadata.getNamedParameterDescriptor( name ).isJpaStyle(); diff --git a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java index e01390290b..9584f9725a 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java @@ -1574,4 +1574,13 @@ public interface CoreMessageLogger extends BasicLogger { @LogMessage(level = INFO) @Message(value = "NaturalId queries executed to database: %s", id = 442) void naturalIdQueriesExecuted(long naturalIdQueriesExecutionCount); + + @LogMessage(level = WARN) + @Message( + value = "Dialect [%s] limits the number of elements in an IN predicate to %s entries. " + + "However, the given parameter list [%s] contained %s entries, which will likely cause failures " + + "to execute the query in the database", + id = 443 + ) + void tooManyInExpressions(String dialectName, int limit, String paramName, int size); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/criteria/LongInElementsTest.java b/hibernate-core/src/test/java/org/hibernate/test/criteria/LongInElementsTest.java index 90a5ac3353..cb299f9a7a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/criteria/LongInElementsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/criteria/LongInElementsTest.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 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 Inc. From 961caf770a4e6fd4e97d08aef83ee07b247a49e3 Mon Sep 17 00:00:00 2001 From: Jeremy Whiting Date: Wed, 5 Sep 2012 15:05:13 +0100 Subject: [PATCH 30/38] HHH-7568 Added test case to check removal of compound key association items. Changed the detection of JoinColumns to work when orm/hbm xml is used. Added change to configure a property when JoinColumns annotation is used on entity definition. --- .../org/hibernate/cfg/AnnotationBinder.java | 40 ++- .../lazy/CompositeKeyDeleteTest.java | 121 +++++++++ .../specjmapid/lazy/CustomerInventoryTwo.java | 147 +++++++++++ .../lazy/CustomerInventoryTwoPK.java | 67 +++++ .../e1/b/specjmapid/lazy/CustomerTwo.java | 248 ++++++++++++++++++ .../e1/b/specjmapid/lazy/hbm_order.xml | 55 ++++ .../e1/b/specjmapid/lazy/order_orm.xml | 33 +++ 7 files changed, 700 insertions(+), 11 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CompositeKeyDeleteTest.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwo.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwoPK.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerTwo.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/hbm_order.xml create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/order_orm.xml diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java index 5ff2bd768f..9a3e26d375 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java @@ -53,6 +53,7 @@ import javax.persistence.Id; import javax.persistence.IdClass; import javax.persistence.InheritanceType; import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; @@ -1393,17 +1394,34 @@ public final class AnnotationBinder { if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) { String columnName = element.getAnnotation( Column.class ).name(); for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) { - if ( prop.isAnnotationPresent( JoinColumn.class ) - && prop.getAnnotation( JoinColumn.class ).name().equals( columnName ) - && !prop.isAnnotationPresent( MapsId.class ) ) { - //create a PropertyData fpr the specJ property holding the mapping - PropertyData specJPropertyData = new PropertyInferredData( - declaringClass, //same dec - prop, // the actual @XToOne property - propertyAccessor, //TODO we should get the right accessor but the same as id would do - mappings.getReflectionManager() - ); - mappings.addPropertyAnnotatedWithMapsIdSpecj( entity, specJPropertyData, element.toString() ); + if ( !prop.isAnnotationPresent( MapsId.class ) ) { + /** + * The detection of a configured individual JoinColumn differs between Annotation + * and XML configuration processing. + */ + boolean isRequiredAnnotationPresent = false; + JoinColumns groupAnnotation = prop.getAnnotation(JoinColumns.class); + if ( ( prop.isAnnotationPresent( JoinColumn.class ) + && prop.getAnnotation( JoinColumn.class ).name().equals( columnName ) ) ) { + isRequiredAnnotationPresent = true; + } else if ( prop.isAnnotationPresent( JoinColumns.class ) ) { + for ( JoinColumn columnAnnotation : groupAnnotation.value() ) { + if ( columnName.equals(columnAnnotation.name() ) ) { + isRequiredAnnotationPresent = true; + break; + } + } + } + if ( isRequiredAnnotationPresent ) { + //create a PropertyData fpr the specJ property holding the mapping + PropertyData specJPropertyData = new PropertyInferredData( + declaringClass, //same dec + prop, // the actual @XToOne property + propertyAccessor, //TODO we should get the right accessor but the same as id would do + mappings.getReflectionManager() + ); + mappings.addPropertyAnnotatedWithMapsIdSpecj( entity, specJPropertyData, element.toString() ); + } } } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CompositeKeyDeleteTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CompositeKeyDeleteTest.java new file mode 100644 index 0000000000..52b2266560 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CompositeKeyDeleteTest.java @@ -0,0 +1,121 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates 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, 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 + * 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.test.annotations.derivedidentities.e1.b.specjmapid.lazy; + +import java.math.BigDecimal; +import java.util.List; + +import junit.framework.Assert; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.derivedidentities.e1.b.specjmapid.Item; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.junit.Test; + +public class CompositeKeyDeleteTest extends BaseCoreFunctionalTestCase { + + public String[] getMappings() { + return new String[] { "annotations/derivedidentities/e1/b/specjmapid/lazy/order_orm.xml" }; + } + + public CompositeKeyDeleteTest() { + System.setProperty( "hibernate.enable_specj_proprietary_syntax", "true" ); + } + /** + * This test checks to make sure the non null column is not updated with a + * null value when a CustomerInventory is removed. + */ + @Test + public void testRemove() { + Session s = openSession(); + Transaction tx = s.beginTransaction(); + + CustomerTwo c1 = new CustomerTwo( + "foo", "bar", "contact1", "100", new BigDecimal( 1000 ), new BigDecimal( 1000 ), new BigDecimal( 1000 ) + ); + + s.persist( c1 ); + s.flush(); + s.clear(); + + Item boat = new Item(); + boat.setId( "1" ); + boat.setName( "cruiser" ); + boat.setPrice( new BigDecimal( 500 ) ); + boat.setDescription( "a boat" ); + boat.setCategory( 42 ); + + s.persist( boat ); + + + Item house = new Item(); + house.setId( "2" ); + house.setName( "blada" ); + house.setPrice( new BigDecimal( 5000 ) ); + house.setDescription( "a house" ); + house.setCategory( 74 ); + + s.persist( house ); + s.flush(); + s.clear(); + + c1.addInventory( boat, 10, new BigDecimal( 5000 ) ); + + c1.addInventory( house, 100, new BigDecimal( 50000 ) ); + s.merge( c1 ); + Integer id = c1.getId(); + tx.commit(); + s.close(); + + s = openSession(); + tx = s.beginTransaction(); + + CustomerTwo c12 = ( CustomerTwo) s.createQuery( "select c from CustomerTwo c" ).uniqueResult(); + Assert.assertNotNull(c12); + List list = c12.getInventories(); + Assert.assertNotNull(list); + Assert.assertEquals(2, list.size()); + CustomerInventoryTwo ci = list.get(1); + list.remove(ci); + s.delete(ci); + s.flush(); + + tx.commit();//fail + s.close(); + + } + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { + CustomerTwo.class, + CustomerInventoryTwo.class, + CustomerInventoryTwoPK.class, + Item.class + + }; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwo.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwo.java new file mode 100644 index 0000000000..ea34c711be --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwo.java @@ -0,0 +1,147 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates 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, 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 + * 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.test.annotations.derivedidentities.e1.b.specjmapid.lazy; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Comparator; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.TableGenerator; +import javax.persistence.Version; + +import org.hibernate.test.annotations.derivedidentities.e1.b.specjmapid.Item; + +@NamedQueries({ @NamedQuery(name = "CustomerInventoryTwo.selectAll", query = "select a from CustomerInventoryTwo a") }) +@SuppressWarnings("serial") +@Entity +@Table(name = "O_CUSTINVENTORY") +@IdClass(CustomerInventoryTwoPK.class) +public class CustomerInventoryTwo implements Serializable, + Comparator { + + @Id + @TableGenerator(name = "inventory", table = "U_SEQUENCES", pkColumnName = "S_ID", valueColumnName = "S_NEXTNUM", pkColumnValue = "inventory", allocationSize = 1000) + @GeneratedValue(strategy = GenerationType.TABLE, generator = "inventory") + @Column(name = "CI_ID") + private Integer id; + + @Id + @Column(name = "CI_CUSTOMERID", insertable = false, updatable = false) + private int custId; + + @ManyToOne(cascade = CascadeType.MERGE) + @JoinColumn(name = "CI_CUSTOMERID", nullable = false) + private CustomerTwo customer; + + @ManyToOne(cascade = CascadeType.MERGE) + @JoinColumn(name = "CI_ITEMID") + private Item vehicle; + + @Column(name = "CI_VALUE") + private BigDecimal totalCost; + + @Column(name = "CI_QUANTITY") + private int quantity; + + @Version + @Column(name = "CI_VERSION") + private int version; + + protected CustomerInventoryTwo() { + } + + CustomerInventoryTwo(CustomerTwo customer, Item vehicle, int quantity, + BigDecimal totalValue) { + this.customer = customer; + this.vehicle = vehicle; + this.quantity = quantity; + this.totalCost = totalValue; + } + + public Item getVehicle() { + return vehicle; + } + + public BigDecimal getTotalCost() { + return totalCost; + } + + public int getQuantity() { + return quantity; + } + + public Integer getId() { + return id; + } + + public CustomerTwo getCustomer() { + return customer; + } + + public int getCustId() { + return custId; + } + + public int getVersion() { + return version; + } + + public int compare(CustomerInventoryTwo cdb1, CustomerInventoryTwo cdb2) { + return cdb1.id.compareTo(cdb2.id); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj == null || !(obj instanceof CustomerInventoryTwo)) { + return false; + } + if (this.id == ((CustomerInventoryTwo) obj).id) { + return true; + } + if (this.id != null && ((CustomerInventoryTwo) obj).id == null) { + return false; + } + if (this.id == null && ((CustomerInventoryTwo) obj).id != null) { + return false; + } + + return this.id.equals(((CustomerInventoryTwo) obj).id); + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwoPK.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwoPK.java new file mode 100644 index 0000000000..236290a979 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwoPK.java @@ -0,0 +1,67 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates 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, 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 + * 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.test.annotations.derivedidentities.e1.b.specjmapid.lazy; + +import java.io.Serializable; + +public class CustomerInventoryTwoPK implements Serializable { + + private Integer id; + private int custId; + + public CustomerInventoryTwoPK() { + } + + public CustomerInventoryTwoPK(Integer id, int custId) { + this.id = id; + this.custId = custId; + } + + public boolean equals(Object other) { + if ( other == this ) { + return true; + } + if ( other == null || getClass() != other.getClass() ) { + return false; + } + CustomerInventoryTwoPK cip = ( CustomerInventoryTwoPK ) other; + return ( custId == cip.custId && ( id == cip.id || + ( id != null && id.equals( cip.id ) ) ) ); + } + + public int hashCode() { + return ( id == null ? 0 : id.hashCode() ) ^ custId; + } + + public Integer getId() { + return id; + } + + public int getCustId() { + return custId; + } + + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerTwo.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerTwo.java new file mode 100644 index 0000000000..d548959eea --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerTwo.java @@ -0,0 +1,248 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates 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, 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 + * 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.test.annotations.derivedidentities.e1.b.specjmapid.lazy; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Version; + +import org.hibernate.test.annotations.derivedidentities.e1.b.specjmapid.Item; + +@SuppressWarnings("serial") +@NamedQueries({ + @NamedQuery(name = CustomerTwo.QUERY_ALL, + query = "select a from CustomerTwo a"), + @NamedQuery(name = CustomerTwo.QUERY_COUNT, + query = "select COUNT(a) from CustomerTwo a"), + @NamedQuery(name = CustomerTwo.QUERY_BY_CREDIT, + query = "SELECT c.id FROM CustomerTwo c WHERE c.creditLimit > :limit") +}) +@Entity +@Table(name = "O_CUSTOMER") +public class CustomerTwo implements Serializable{ + public static final String QUERY_ALL = "CustomerTwo.selectAll"; + public static final String QUERY_COUNT = "CustomerTwo.count"; + public static final String QUERY_BY_CREDIT = "CustomerTwo.selectByCreditLimit"; + + public static final String BAD_CREDIT = "BC"; + + @Id + @Column(name = "C_ID") + private int id; + + @Column(name = "C_FIRST") + private String firstName; + + @Column(name = "C_LAST") + private String lastName; + + @Column(name = "C_CONTACT") + private String contact; + + @Column(name = "C_CREDIT") + private String credit; + + @Column(name = "C_CREDIT_LIMIT") + private BigDecimal creditLimit; + + @Column(name = "C_SINCE") + @Temporal(TemporalType.DATE) + private Calendar since; + + @Column(name = "C_BALANCE") + private BigDecimal balance; + + @Column(name = "C_YTD_PAYMENT") + private BigDecimal ytdPayment; + + @OneToMany(targetEntity = CustomerInventoryTwo.class, + mappedBy = "customer", + cascade = CascadeType.ALL, + fetch = FetchType.EAGER) + private List customerInventories; + + + @Version + @Column(name = "C_VERSION") + private int version; + + protected CustomerTwo() { + } + + public CustomerTwo(String first, String last, + String contact, String credit, BigDecimal creditLimit, + BigDecimal balance, BigDecimal YtdPayment) { + + this.firstName = first; + this.lastName = last; + this.contact = contact; + this.since = Calendar.getInstance(); + this.credit = credit; + this.creditLimit = creditLimit; + this.balance = balance; + this.ytdPayment = YtdPayment; + } + + public Integer getId() { + return id; + } + + public void setId(Integer customerId) { + this.id = customerId; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getContact() { + return contact; + } + + public void setContact(String contact) { + this.contact = contact; + } + + public String getCredit() { + return credit; + } + + public void setCredit(String credit) { + this.credit = credit; + } + + public BigDecimal getCreditLimit() { + return creditLimit; + } + + public void setCreditLimit(BigDecimal creditLimit) { + this.creditLimit = creditLimit; + } + + public Calendar getSince() { + return since; + } + + public void setSince(Calendar since) { + this.since = since; + } + + public BigDecimal getBalance() { + return balance; + } + + public void setBalance(BigDecimal balance) { + this.balance = balance; + } + + public void changeBalance(BigDecimal change) { + setBalance( balance.add( change ).setScale( 2, BigDecimal.ROUND_DOWN ) ); + } + + public BigDecimal getYtdPayment() { + return ytdPayment; + } + + public void setYtdPayment(BigDecimal ytdPayment) { + this.ytdPayment = ytdPayment; + } + + + public List getInventories() { + if ( this.customerInventories == null ) { + this.customerInventories = new ArrayList(); + } + return this.customerInventories; + } + + public CustomerInventoryTwo addInventory(Item item, int quantity, + BigDecimal totalValue) { + + CustomerInventoryTwo inventory = new CustomerInventoryTwo( + this, item, + quantity, totalValue + ); + getInventories().add( inventory ); + return inventory; + } + + public int getVersion() { + return version; + } + + public boolean hasSufficientCredit(BigDecimal amount) { + return !BAD_CREDIT.equals( getCredit() ) + && creditLimit != null + && creditLimit.compareTo( amount ) >= 0; + } + + @Override + public boolean equals(Object o) { + if ( this == o ) { + return true; + } + if ( o == null || getClass() != o.getClass() ) { + return false; + } + return id == ( ( CustomerTwo ) o ).id; + } + + @Override + public int hashCode() { + return new Integer( id ).hashCode(); + } + + @Override + public String toString() { + return this.getFirstName() + " " + this.getLastName(); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/hbm_order.xml b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/hbm_order.xml new file mode 100644 index 0000000000..511abfbb59 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/hbm_order.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/order_orm.xml b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/order_orm.xml new file mode 100644 index 0000000000..259e3cba10 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/order_orm.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 6a48cccd5d250fb25768fd9c7a28c750f002c6f9 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 5 Sep 2012 12:34:03 -0500 Subject: [PATCH 31/38] HHH-7568 - Add JPA1.0 compound key compatability when orm descriptor file used to override annotations. --- .../org/hibernate/cfg/AnnotationBinder.java | 62 +++++++++++-------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java index 9a3e26d375..451939fc89 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java @@ -1395,33 +1395,41 @@ public final class AnnotationBinder { String columnName = element.getAnnotation( Column.class ).name(); for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) { if ( !prop.isAnnotationPresent( MapsId.class ) ) { - /** - * The detection of a configured individual JoinColumn differs between Annotation - * and XML configuration processing. - */ - boolean isRequiredAnnotationPresent = false; - JoinColumns groupAnnotation = prop.getAnnotation(JoinColumns.class); - if ( ( prop.isAnnotationPresent( JoinColumn.class ) - && prop.getAnnotation( JoinColumn.class ).name().equals( columnName ) ) ) { - isRequiredAnnotationPresent = true; - } else if ( prop.isAnnotationPresent( JoinColumns.class ) ) { - for ( JoinColumn columnAnnotation : groupAnnotation.value() ) { - if ( columnName.equals(columnAnnotation.name() ) ) { - isRequiredAnnotationPresent = true; - break; - } - } - } - if ( isRequiredAnnotationPresent ) { - //create a PropertyData fpr the specJ property holding the mapping - PropertyData specJPropertyData = new PropertyInferredData( - declaringClass, //same dec - prop, // the actual @XToOne property - propertyAccessor, //TODO we should get the right accessor but the same as id would do - mappings.getReflectionManager() - ); - mappings.addPropertyAnnotatedWithMapsIdSpecj( entity, specJPropertyData, element.toString() ); - } + /** + * The detection of a configured individual JoinColumn differs between Annotation + * and XML configuration processing. + */ + boolean isRequiredAnnotationPresent = false; + JoinColumns groupAnnotation = prop.getAnnotation( JoinColumns.class ); + if ( (prop.isAnnotationPresent( JoinColumn.class ) + && prop.getAnnotation( JoinColumn.class ).name().equals( columnName )) ) { + isRequiredAnnotationPresent = true; + } + else if ( prop.isAnnotationPresent( JoinColumns.class ) ) { + for ( JoinColumn columnAnnotation : groupAnnotation.value() ) { + if ( columnName.equals( columnAnnotation.name() ) ) { + isRequiredAnnotationPresent = true; + break; + } + } + } + if ( isRequiredAnnotationPresent ) { + //create a PropertyData fpr the specJ property holding the mapping + PropertyData specJPropertyData = new PropertyInferredData( + declaringClass, + //same dec + prop, + // the actual @XToOne property + propertyAccessor, + //TODO we should get the right accessor but the same as id would do + mappings.getReflectionManager() + ); + mappings.addPropertyAnnotatedWithMapsIdSpecj( + entity, + specJPropertyData, + element.toString() + ); + } } } } From 7b04acd4f41f0790fd11f84db2d1d180e7dfd291 Mon Sep 17 00:00:00 2001 From: brmeyer Date: Wed, 5 Sep 2012 12:14:14 -0400 Subject: [PATCH 32/38] HHH-7569 Merging test changes to master that were made only in 4.1 branch --- .../type/SerializableToBlobType.java | 19 ++-- .../entity/IdentifierGeneratorTest.java | 20 +++-- .../collectionelement/ordered/Person.java | 7 ++ .../embeddables/EmbeddableIntegratorTest.java | 13 +-- .../filter/secondarytable/User.java | 10 ++- .../filter/subclass/joined/Mammal.java | 2 + .../filter/subclass/singletable/Mammal.java | 2 + .../filter/subclass/tableperclass/Mammal.java | 2 + .../id/sequences/HibernateSequenceTest.java | 3 + .../test/annotations/lob/EntitySerialize.java | 44 +++++++++ .../annotations/lob/ExplicitSerializable.java | 23 +++++ .../lob/ExplicitSerializableType.java | 30 +++++++ .../annotations/lob/ImplicitSerializable.java | 23 +++++ .../lob/ImplicitSerializableType.java | 31 +++++++ .../lob/SerializableToBlobTypeTest.java | 89 +++++++++++++++++++ .../connections/AggressiveReleaseTest.java | 16 ++-- .../BasicConnectionProviderTest.java | 3 + .../ConnectionManagementTestCase.java | 3 + .../CurrentSessionConnectionTest.java | 3 + .../connections/SuppliedConnectionTest.java | 3 + .../ThreadLocalCurrentSessionTest.java | 3 + .../CommandExtractorServiceTest.java | 7 +- .../test/propertyref/DoesNotWorkTest.java | 8 +- .../propertyref/DoesNotWorkWithHbmTest.java | 13 +-- .../SchemaExportSuppliedConnectionTest.java | 13 --- .../test/schemaupdate/SchemaExportTest.java | 38 ++++++-- .../service/ServiceBootstrappingTest.java | 16 ++-- .../transaction/jta/ManagedDrivingTest.java | 25 +++--- 28 files changed, 386 insertions(+), 83 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/lob/EntitySerialize.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializable.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializableType.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializable.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializableType.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/lob/SerializableToBlobTypeTest.java diff --git a/hibernate-core/src/main/java/org/hibernate/type/SerializableToBlobType.java b/hibernate-core/src/main/java/org/hibernate/type/SerializableToBlobType.java index d11ea335a0..e7eb70ebe7 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/SerializableToBlobType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/SerializableToBlobType.java @@ -34,7 +34,6 @@ import java.util.Map; import java.util.Properties; import org.dom4j.Node; - import org.hibernate.Hibernate; import org.hibernate.HibernateException; import org.hibernate.MappingException; @@ -43,14 +42,14 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.SerializationHelper; -import org.hibernate.usertype.ParameterizedType; +import org.hibernate.usertype.DynamicParameterizedType; /** * @author Emmanuel Bernard */ -public class SerializableToBlobType extends AbstractLobType implements ParameterizedType { +public class SerializableToBlobType extends AbstractLobType implements DynamicParameterizedType { /** - * class name of the serialisable class + * class name of the serialisable class */ public static final String CLASS_NAME = "classname"; private Class serializableClass; @@ -138,17 +137,19 @@ public class SerializableToBlobType extends AbstractLobType implements Parameter } public void setParameterValues(Properties parameters) { - if ( parameters != null ) { + ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE ); + if ( reader != null ) { + serializableClass = reader.getReturnedClass(); + } + else { String className = parameters.getProperty( CLASS_NAME ); if ( className == null ) { - throw new MappingException( - "No class name defined for type: " + SerializableToBlobType.class.getName() - ); + throw new MappingException( "No class name defined for type: " + SerializableToBlobType.class.getName() ); } try { serializableClass = ReflectHelper.classForName( className ); } - catch (ClassNotFoundException e) { + catch ( ClassNotFoundException e ) { throw new MappingException( "Unable to load class from " + CLASS_NAME + " parameter", e ); } } diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/IdentifierGeneratorTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/IdentifierGeneratorTest.java index 1e54fc4fa2..3180f826e7 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/IdentifierGeneratorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/IdentifierGeneratorTest.java @@ -24,14 +24,20 @@ package org.hibernate.metamodel.source.annotations.entity; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertTrue; +import static junit.framework.Assert.fail; + import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import org.junit.Test; - import org.hibernate.annotations.GenericGenerator; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.dialect.H2Dialect; import org.hibernate.id.Assigned; import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.IdentityGenerator; @@ -42,17 +48,13 @@ import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.binding.EntityBinding; import org.hibernate.metamodel.binding.EntityIdentifier; import org.hibernate.metamodel.source.MappingException; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertTrue; -import static junit.framework.Assert.fail; +import org.hibernate.testing.RequiresDialect; +import org.junit.Test; /** * @author Hardy Ferentschik */ +@RequiresDialect(H2Dialect.class) public class IdentifierGeneratorTest extends BaseAnnotationBindingTestCase { @Entity class NoGenerationEntity { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/ordered/Person.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/ordered/Person.java index 3db5a4fa51..1894d9b96b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/ordered/Person.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/ordered/Person.java @@ -28,6 +28,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; import javax.persistence.OrderBy; import java.util.HashSet; @@ -74,6 +75,7 @@ public class Person { @ElementCollection @JoinColumn + @JoinTable(name = "T_NICKNAMES_A") @OrderBy public Set getNickNamesAscendingNaturalSort() { return nickNamesAscendingNaturalSort; @@ -85,6 +87,7 @@ public class Person { @ElementCollection @JoinColumn + @JoinTable(name = "T_NICKNAMES_D") @OrderBy( "desc" ) public Set getNickNamesDescendingNaturalSort() { return nickNamesDescendingNaturalSort; @@ -98,6 +101,7 @@ public class Person { @ElementCollection @JoinColumn @OrderBy + @JoinTable(name = "T_ADDRESS_A") public Set
    getAddressesAscendingNaturalSort() { return addressesAscendingNaturalSort; } @@ -109,6 +113,7 @@ public class Person { @ElementCollection @JoinColumn @OrderBy( "desc" ) + @JoinTable(name = "T_ADDRESS_D") public Set
    getAddressesDescendingNaturalSort() { return addressesDescendingNaturalSort; } @@ -120,6 +125,7 @@ public class Person { @ElementCollection @JoinColumn @OrderBy( "city" ) + @JoinTable(name = "T_ADD_CITY_A") public Set
    getAddressesCityAscendingSort() { return addressesCityAscendingSort; } @@ -131,6 +137,7 @@ public class Person { @ElementCollection @JoinColumn @OrderBy( "city desc" ) + @JoinTable(name = "T_ADD_CITY_D") public Set
    getAddressesCityDescendingSort() { return addressesCityDescendingSort; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java index 568559ea4e..6f3defb65a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java @@ -23,6 +23,8 @@ */ package org.hibernate.test.annotations.embeddables; +import static org.junit.Assert.assertEquals; + import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; @@ -32,20 +34,19 @@ import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl; import org.hibernate.cfg.Configuration; +import org.hibernate.dialect.H2Dialect; import org.hibernate.exception.GenericJDBCException; import org.hibernate.service.ServiceRegistry; -import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl; - -import org.junit.Test; - +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.junit4.BaseUnitTestCase; - -import static org.junit.Assert.assertEquals; +import org.junit.Test; /** * @author Chris Pheby */ +@RequiresDialect(H2Dialect.class) public class EmbeddableIntegratorTest extends BaseUnitTestCase { /** diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/secondarytable/User.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/secondarytable/User.java index bbbd76dba3..02c68c5d48 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/secondarytable/User.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/secondarytable/User.java @@ -11,13 +11,14 @@ import org.hibernate.annotations.Filter; import org.hibernate.annotations.FilterDef; import org.hibernate.annotations.ParamDef; import org.hibernate.annotations.SqlFragmentAlias; +import org.hibernate.annotations.Type; @Entity -@Table(name="USER") +@Table(name="T_USER") @SecondaryTable(name="SECURITY_USER") @FilterDef(name="ageFilter", parameters=@ParamDef(name="age", type="integer")) @Filter(name="ageFilter", condition="{u}.AGE < :age AND {s}.LOCKED_OUT <> 1", - aliases={@SqlFragmentAlias(alias="u", table="USER"), @SqlFragmentAlias(alias="s", table="SECURITY_USER")}) + aliases={@SqlFragmentAlias(alias="u", table="T_USER"), @SqlFragmentAlias(alias="s", table="SECURITY_USER")}) public class User { @Id @@ -31,13 +32,14 @@ public class User { @Column(name="AGE") private int age; - @Column(name="USERNAME", table="SECURITY_USER") + @Column(name="SECURITY_USERNAME", table="SECURITY_USER") private String username; - @Column(name="PASSWORD", table="SECURITY_USER") + @Column(name="SECURITY_PASSWORD", table="SECURITY_USER") private String password; @Column(name="LOCKED_OUT", table="SECURITY_USER") + @Type( type = "numeric_boolean") private boolean lockedOut; public int getId() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/joined/Mammal.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/joined/Mammal.java index 0db20e43d6..a77e8f3c6b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/joined/Mammal.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/joined/Mammal.java @@ -6,6 +6,7 @@ import javax.persistence.Table; import org.hibernate.annotations.Filter; import org.hibernate.annotations.FilterDef; +import org.hibernate.annotations.Type; @Entity @Table(name="ZOOLOGY_MAMMAL") @@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef; public class Mammal extends Animal{ @Column(name="IS_PREGNANT") + @Type( type="numeric_boolean" ) private boolean isPregnant; public boolean isPregnant() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/singletable/Mammal.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/singletable/Mammal.java index 47f0f72310..483bcc5e2d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/singletable/Mammal.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/singletable/Mammal.java @@ -6,6 +6,7 @@ import javax.persistence.Table; import org.hibernate.annotations.Filter; import org.hibernate.annotations.FilterDef; +import org.hibernate.annotations.Type; @Entity @Table(name="ZOOLOGY_MAMMAL") @@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef; public class Mammal extends Animal{ @Column(name="IS_PREGNANT") + @Type( type="numeric_boolean" ) private boolean isPregnant; public boolean isPregnant() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/tableperclass/Mammal.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/tableperclass/Mammal.java index 7e4af107fa..23e1b374af 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/tableperclass/Mammal.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/tableperclass/Mammal.java @@ -6,6 +6,7 @@ import javax.persistence.Table; import org.hibernate.annotations.Filter; import org.hibernate.annotations.FilterDef; +import org.hibernate.annotations.Type; @Entity @Table(name="ZOOLOGY_MAMMAL") @@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef; public class Mammal extends Animal{ @Column(name="IS_PREGNANT") + @Type( type="numeric_boolean" ) private boolean isPregnant; public boolean isPregnant() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/HibernateSequenceTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/HibernateSequenceTest.java index 246b193abc..624ee0f201 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/HibernateSequenceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/HibernateSequenceTest.java @@ -7,11 +7,13 @@ import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; +import org.hibernate.dialect.H2Dialect; import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.mapping.Table; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.test.annotations.id.sequences.entities.HibernateSequenceEntity; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; @@ -19,6 +21,7 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) */ @TestForIssue(jiraKey = "HHH-6068") +@RequiresDialect( value = H2Dialect.class) public class HibernateSequenceTest extends BaseCoreFunctionalTestCase { private static final String SCHEMA_NAME = "OTHER_SCHEMA"; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/EntitySerialize.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/EntitySerialize.java new file mode 100644 index 0000000000..879e66766b --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/EntitySerialize.java @@ -0,0 +1,44 @@ +package org.hibernate.test.annotations.lob; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Lob; + +import org.hibernate.annotations.Type; +import org.hibernate.annotations.TypeDef; +import org.hibernate.annotations.TypeDefs; + +/** + * @author Janario Oliveira + */ +@Entity +@TypeDefs({ @TypeDef(typeClass = ImplicitSerializableType.class, defaultForType = ImplicitSerializable.class) }) +public class EntitySerialize { + @Id + @GeneratedValue + long id; + + @Lob + ExplicitSerializable explicitLob; + + @Type(type = "org.hibernate.test.annotations.lob.ExplicitSerializableType") + ExplicitSerializable explicit; + + ImplicitSerializable implicit; + + @Type(type = "org.hibernate.test.annotations.lob.ExplicitSerializableType") + ImplicitSerializable explicitOverridingImplicit; + + /** + * common in ExplicitSerializable and ImplicitSerializable to create same property in both + * This property will not persist it have a default value per type + * + * @author Janario Oliveira + */ + public interface CommonSerializable { + String getDefaultValue(); + + void setDefaultValue(String defaultValue); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializable.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializable.java new file mode 100644 index 0000000000..75f15d48e3 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializable.java @@ -0,0 +1,23 @@ +package org.hibernate.test.annotations.lob; + +import java.io.Serializable; + +import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable; + +/** + * @author Janario Oliveira + */ +public class ExplicitSerializable implements Serializable, CommonSerializable { + String defaultValue; + String value; + + @Override + public String getDefaultValue() { + return defaultValue; + } + + @Override + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializableType.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializableType.java new file mode 100644 index 0000000000..13effc1804 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializableType.java @@ -0,0 +1,30 @@ +package org.hibernate.test.annotations.lob; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable; +import org.hibernate.type.SerializableToBlobType; + +/** + * @author Janario Oliveira + */ +public class ExplicitSerializableType extends SerializableToBlobType { + @Override + public Object get(ResultSet rs, String name) throws SQLException { + CommonSerializable deserialize = (CommonSerializable) super.get( rs, name ); + deserialize.setDefaultValue( "EXPLICIT" ); + return deserialize; + } + + @Override + public void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException { + if ( value != null ) { + ( (CommonSerializable) value ).setDefaultValue( null ); + } + super.set( st, value, index, session ); + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializable.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializable.java new file mode 100644 index 0000000000..7f5a894048 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializable.java @@ -0,0 +1,23 @@ +package org.hibernate.test.annotations.lob; + +import java.io.Serializable; + +import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable; + +/** + * @author Janario Oliveira + */ +public class ImplicitSerializable implements Serializable, CommonSerializable { + String defaultValue; + String value; + + @Override + public String getDefaultValue() { + return defaultValue; + } + + @Override + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializableType.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializableType.java new file mode 100644 index 0000000000..c88fb14dea --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializableType.java @@ -0,0 +1,31 @@ +package org.hibernate.test.annotations.lob; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable; +import org.hibernate.type.SerializableToBlobType; + +/** + * @author Janario Oliveira + */ +public class ImplicitSerializableType extends SerializableToBlobType { + + @Override + public Object get(ResultSet rs, String name) throws SQLException { + CommonSerializable deserialize = (CommonSerializable) super.get( rs, name ); + deserialize.setDefaultValue( "IMPLICIT" ); + return deserialize; + } + + @Override + public void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException { + if ( value != null ) { + ( (CommonSerializable) value ).setDefaultValue( null ); + } + super.set( st, value, index, session ); + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/SerializableToBlobTypeTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/SerializableToBlobTypeTest.java new file mode 100644 index 0000000000..6d82206a78 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/SerializableToBlobTypeTest.java @@ -0,0 +1,89 @@ +package org.hibernate.test.annotations.lob; + +import static org.junit.Assert.assertEquals; + +import org.hibernate.Session; +import org.hibernate.cfg.Configuration; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.hibernate.type.SerializableToBlobType; +import org.hibernate.type.Type; +import org.junit.Test; + +/** + * Test type definition for SerializableToBlobType + * + * @author Janario Oliveira + */ +public class SerializableToBlobTypeTest extends BaseCoreFunctionalTestCase { + @Test + public void testTypeDefinition() { + Configuration cfg = configuration(); + PersistentClass pc = cfg.getClassMapping( EntitySerialize.class.getName() ); + + // explicitLob of SerializableToBlobType + Type explicitLobType = pc.getProperty( "explicitLob" ).getType(); + assertEquals( ExplicitSerializable.class, explicitLobType.getReturnedClass() ); + assertEquals( SerializableToBlobType.class.getName(), explicitLobType.getName() ); + + // explicit of ExplicitSerializableType + Type explicitType = pc.getProperty( "explicit" ).getType(); + assertEquals( ExplicitSerializable.class, explicitType.getReturnedClass() ); + assertEquals( ExplicitSerializableType.class.getName(), explicitType.getName() ); + + // implicit of ImplicitSerializableType + Type implicitType = pc.getProperty( "implicit" ).getType(); + assertEquals( ImplicitSerializable.class, implicitType.getReturnedClass() ); + assertEquals( ImplicitSerializableType.class.getName(), implicitType.getName() ); + + // explicitOverridingImplicit ExplicitSerializableType overrides ImplicitSerializableType + Type overrideType = pc.getProperty( "explicitOverridingImplicit" ).getType(); + assertEquals( ImplicitSerializable.class, overrideType.getReturnedClass() ); + assertEquals( ExplicitSerializableType.class.getName(), overrideType.getName() ); + } + + @Test + public void testPersist() { + EntitySerialize entitySerialize = new EntitySerialize(); + + entitySerialize.explicitLob = new ExplicitSerializable(); + entitySerialize.explicitLob.value = "explicitLob"; + entitySerialize.explicitLob.defaultValue = "defaultExplicitLob"; + + entitySerialize.explicit = new ExplicitSerializable(); + entitySerialize.explicit.value = "explicit"; + + entitySerialize.implicit = new ImplicitSerializable(); + entitySerialize.implicit.value = "implicit"; + + entitySerialize.explicitOverridingImplicit = new ImplicitSerializable(); + entitySerialize.explicitOverridingImplicit.value = "explicitOverridingImplicit"; + + Session session = openSession(); + session.getTransaction().begin(); + session.persist( entitySerialize ); + + session.getTransaction().commit(); + session.close(); + + session = openSession(); + + EntitySerialize persistedSerialize = (EntitySerialize) session.get( EntitySerialize.class, entitySerialize.id ); + assertEquals( "explicitLob", persistedSerialize.explicitLob.value ); + assertEquals( "explicit", persistedSerialize.explicit.value ); + assertEquals( "implicit", persistedSerialize.implicit.value ); + assertEquals( "explicitOverridingImplicit", persistedSerialize.explicitOverridingImplicit.value ); + + assertEquals( "defaultExplicitLob", persistedSerialize.explicitLob.defaultValue ); + assertEquals( "EXPLICIT", persistedSerialize.explicit.defaultValue ); + assertEquals( "IMPLICIT", persistedSerialize.implicit.defaultValue ); + assertEquals( "EXPLICIT", persistedSerialize.explicitOverridingImplicit.defaultValue ); + + session.close(); + } + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { EntitySerialize.class }; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java index 2db4ec9c42..18bedf59e7 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java @@ -1,34 +1,36 @@ // $Id: AggressiveReleaseTest.java 10977 2006-12-12 23:28:04Z steve.ebersole@jboss.com $ package org.hibernate.test.connections; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.sql.Connection; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.junit.Test; - import org.hibernate.ConnectionReleaseMode; import org.hibernate.Hibernate; import org.hibernate.ScrollableResults; import org.hibernate.Session; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; +import org.hibernate.dialect.H2Dialect; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; import org.hibernate.internal.util.SerializationHelper; -import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.jta.TestingJtaBootstrap; import org.hibernate.testing.jta.TestingJtaPlatformImpl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.Test; /** * Implementation of AggressiveReleaseTest. * * @author Steve Ebersole */ +@RequiresDialect(H2Dialect.class) public class AggressiveReleaseTest extends ConnectionManagementTestCase { @Override public void configure(Configuration cfg) { diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/BasicConnectionProviderTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/BasicConnectionProviderTest.java index c297fd862d..a147c0e3b2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/connections/BasicConnectionProviderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/connections/BasicConnectionProviderTest.java @@ -27,12 +27,15 @@ import org.hibernate.ConnectionReleaseMode; import org.hibernate.Session; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; +import org.hibernate.dialect.H2Dialect; +import org.hibernate.testing.RequiresDialect; /** * Implementation of BasicConnectionProviderTest. * * @author Steve Ebersole */ +@RequiresDialect(H2Dialect.class) public class BasicConnectionProviderTest extends ConnectionManagementTestCase { @Override protected Session getSessionUnderTest() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java b/hibernate-core/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java index ea05784213..c7205a856d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java +++ b/hibernate-core/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java @@ -26,7 +26,9 @@ import org.junit.Test; import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.dialect.H2Dialect; import org.hibernate.internal.util.SerializationHelper; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertFalse; @@ -45,6 +47,7 @@ import static org.junit.Assert.fail; * * @author Steve Ebersole */ + public abstract class ConnectionManagementTestCase extends BaseCoreFunctionalTestCase { @Override public final String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/CurrentSessionConnectionTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/CurrentSessionConnectionTest.java index 7caa8d8ecb..380795baa5 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/connections/CurrentSessionConnectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/connections/CurrentSessionConnectionTest.java @@ -24,12 +24,15 @@ package org.hibernate.test.connections; import org.hibernate.Session; +import org.hibernate.dialect.H2Dialect; +import org.hibernate.testing.RequiresDialect; /** * Implementation of CurrentSessionConnectionTest. * * @author Steve Ebersole */ +@RequiresDialect(H2Dialect.class) public class CurrentSessionConnectionTest extends AggressiveReleaseTest { @Override protected Session getSessionUnderTest() throws Throwable { diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java index 32525c5289..b329a6a0e3 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java @@ -31,11 +31,13 @@ import org.hibernate.ConnectionReleaseMode; import org.hibernate.Session; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; +import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.spi.Stoppable; import org.hibernate.testing.AfterClassOnce; import org.hibernate.testing.BeforeClassOnce; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.env.ConnectionProviderBuilder; import org.hibernate.tool.hbm2ddl.SchemaExport; @@ -44,6 +46,7 @@ import org.hibernate.tool.hbm2ddl.SchemaExport; * * @author Steve Ebersole */ +@RequiresDialect(H2Dialect.class) public class SuppliedConnectionTest extends ConnectionManagementTestCase { private ConnectionProvider cp = ConnectionProviderBuilder.buildConnectionProvider(); private Connection connectionUnderTest; diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java index fdb09dee3a..baeb37bd53 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java @@ -30,8 +30,10 @@ import org.hibernate.Session; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.context.internal.ThreadLocalSessionContext; +import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.transaction.spi.LocalStatus; +import org.hibernate.testing.RequiresDialect; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -41,6 +43,7 @@ import static org.junit.Assert.fail; /** * @author Steve Ebersole */ +@RequiresDialect(H2Dialect.class) public class ThreadLocalCurrentSessionTest extends ConnectionManagementTestCase { @Override public void configure(Configuration cfg) { diff --git a/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java b/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java index 5f37af583f..793749f250 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java @@ -26,7 +26,8 @@ package org.hibernate.test.fileimport; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; - +import org.hibernate.dialect.H2Dialect; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor; import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor; @@ -35,6 +36,10 @@ import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor; * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) */ @TestForIssue( jiraKey = "HHH-2403" ) +@RequiresDialect(value = H2Dialect.class, + jiraKey = "HHH-6286", + comment = "Only running the tests against H2, because the sql statements in the import file are not generic. " + + "This test should actually not test directly against the db") public class CommandExtractorServiceTest extends MultiLineImportFileTest { @Override public void configure(Configuration cfg) { diff --git a/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkTest.java b/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkTest.java index a15f6e6bdd..9a31f474e6 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkTest.java @@ -23,20 +23,20 @@ */ package org.hibernate.test.propertyref; -import java.util.Arrays; import java.util.List; import org.hibernate.Session; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; - -import org.junit.Test; - +import org.hibernate.dialect.H2Dialect; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.junit.Test; /** * @author Steve Ebersole */ +@RequiresDialect(H2Dialect.class) public class DoesNotWorkTest extends BaseCoreFunctionalTestCase { @Override protected Class[] getAnnotatedClasses() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkWithHbmTest.java b/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkWithHbmTest.java index 40829b6308..4e973472f9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkWithHbmTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkWithHbmTest.java @@ -23,22 +23,23 @@ */ package org.hibernate.test.propertyref; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.util.List; import org.hibernate.Session; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; - -import org.junit.Test; - +import org.hibernate.dialect.H2Dialect; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.Test; /** * @author Steve Ebersole */ +@RequiresDialect(H2Dialect.class) public class DoesNotWorkWithHbmTest extends BaseCoreFunctionalTestCase { @Override diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportSuppliedConnectionTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportSuppliedConnectionTest.java index 92e9c291e6..4fc2d0fcb2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportSuppliedConnectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportSuppliedConnectionTest.java @@ -37,19 +37,6 @@ import org.hibernate.tool.hbm2ddl.SchemaExport; */ public class SchemaExportSuppliedConnectionTest extends SchemaExportTest { - private ServiceRegistry serviceRegistry; - - @Before - public void setUp() { - serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() ); - } - - @After - public void tearDown() { - ServiceRegistryBuilder.destroy( serviceRegistry ); - serviceRegistry = null; - } - @Override protected SchemaExport createSchemaExport(Configuration cfg) { return new SchemaExport( serviceRegistry, cfg ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java index f30de872f3..a0d55002fd 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java @@ -23,10 +23,15 @@ */ package org.hibernate.test.schemaupdate; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; import org.hibernate.dialect.Dialect; +import org.hibernate.service.ServiceRegistry; +import org.hibernate.testing.ServiceRegistryBuilder; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.tool.hbm2ddl.SchemaExport; @@ -44,6 +49,22 @@ public abstract class SchemaExportTest extends BaseUnitTestCase { return Dialect.getDialect().supportsIfExistsAfterTableName() || Dialect.getDialect() .supportsIfExistsBeforeTableName(); } + protected ServiceRegistry serviceRegistry; + + @Before + public void setUp() { + serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() ); + Configuration cfg = new Configuration(); + cfg.addResource( MAPPING ); + SchemaExport schemaExport = createSchemaExport( cfg ); + schemaExport.drop( true, true ); + } + + @After + public void tearDown() { + ServiceRegistryBuilder.destroy( serviceRegistry ); + serviceRegistry = null; + } @Test public void testCreateAndDropOnlyType() { @@ -52,12 +73,12 @@ public abstract class SchemaExportTest extends BaseUnitTestCase { SchemaExport schemaExport = createSchemaExport( cfg ); // create w/o dropping first; (OK because tables don't exist yet schemaExport.execute( false, true, false, true ); - if ( doesDialectSupportDropTableIfExist() ) { +// if ( doesDialectSupportDropTableIfExist() ) { assertEquals( 0, schemaExport.getExceptions().size() ); - } - else { - assertEquals( 2, schemaExport.getExceptions().size() ); - } +// } +// else { +// assertEquals( 2, schemaExport.getExceptions().size() ); +// } // create w/o dropping again; should be an exception for each table // (2 total) because the tables exist already // assertEquals( 0, schemaExport.getExceptions().size() ); @@ -96,7 +117,12 @@ public abstract class SchemaExportTest extends BaseUnitTestCase { SchemaExport schemaExport = createSchemaExport( cfg ); // should drop before creating, but tables don't exist yet schemaExport.create( true, true ); - assertEquals( 0, schemaExport.getExceptions().size() ); + if ( doesDialectSupportDropTableIfExist() ) { + assertEquals( 0, schemaExport.getExceptions().size() ); + } + else { + assertEquals( 2, schemaExport.getExceptions().size() ); + } // call create again; it should drop tables before re-creating schemaExport.create( true, true ); assertEquals( 0, schemaExport.getExceptions().size() ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java b/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java index ef7f279192..f92c6f060a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java @@ -23,27 +23,29 @@ */ package org.hibernate.test.service; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.Properties; -import org.junit.Test; - import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.cfg.Environment; import org.hibernate.dialect.H2Dialect; -import org.hibernate.engine.jdbc.spi.JdbcServices; -import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.spi.JdbcServices; +import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.env.ConnectionProviderBuilder; import org.hibernate.testing.junit4.BaseUnitTestCase; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.Test; /** * @author Steve Ebersole */ +@RequiresDialect( H2Dialect.class ) public class ServiceBootstrappingTest extends BaseUnitTestCase { @Test public void testBasicBuild() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java index 0524656987..05fd185188 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java @@ -23,44 +23,47 @@ */ package org.hibernate.test.transaction.jta; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; import java.util.HashMap; import java.util.Map; -import javax.transaction.TransactionManager; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import javax.transaction.TransactionManager; import org.hibernate.ConnectionReleaseMode; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.cfg.Environment; +import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor; import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl; import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.engine.transaction.spi.TransactionContext; import org.hibernate.engine.transaction.spi.TransactionImplementor; -import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; -import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.test.common.JournalingTransactionObserver; import org.hibernate.test.common.TransactionContextImpl; import org.hibernate.test.common.TransactionEnvironmentImpl; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.jta.TestingJtaBootstrap; import org.hibernate.testing.junit4.BaseUnitTestCase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; /** * Testing transaction facade handling when the transaction is being driven by something other than the facade. * * @author Steve Ebersole */ +@RequiresDialect(H2Dialect.class) public class ManagedDrivingTest extends BaseUnitTestCase { private StandardServiceRegistryImpl serviceRegistry; From 42de7604f8b04f8ed6ca5408bf942f291e9ac2e7 Mon Sep 17 00:00:00 2001 From: brmeyer Date: Fri, 24 Aug 2012 13:38:31 -0400 Subject: [PATCH 33/38] Fix for HHH-7545 was missing a session close -- caused exception in 3.3 backport. --- .../org/hibernate/test/collectionalias/CollectionAliasTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/CollectionAliasTest.java b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/CollectionAliasTest.java index 90104b4d98..ac1c1e9c58 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/CollectionAliasTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/CollectionAliasTest.java @@ -62,6 +62,7 @@ public class CollectionAliasTest extends BaseCoreFunctionalTestCase { assertEquals( new Integer( 1 ), tableB.getId().getFirstId() ); assertEquals( "a", tableB.getId().getSecondId() ); assertEquals( "b", tableB.getId().getThirdId() ); + s.close(); } @Override From 8b632c214d137b7a744da611a797dc18520c2b56 Mon Sep 17 00:00:00 2001 From: brmeyer Date: Wed, 29 Aug 2012 11:53:29 -0400 Subject: [PATCH 34/38] HHH-4394 Added test case --- .../manytomany/ManyToManyTest.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java index 54fd1e723a..2f75dce8f9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java @@ -314,6 +314,54 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase { s.close(); } + // HHH-4394 + @Test + public void testOrderByContractor() throws Exception { + Session s; + Transaction tx; + s = openSession(); + tx = s.beginTransaction(); + + // create some test entities + Employer employer = new Employer(); + Contractor contractor1 = new Contractor(); + contractor1.setName( "Emmanuel" ); + contractor1.setHourlyRate(100.0f); + Contractor contractor2 = new Contractor(); + contractor2.setName( "Hardy" ); + contractor2.setHourlyRate(99.99f); + s.persist( contractor1 ); + s.persist( contractor2 ); + + // add contractors to employer + List setOfContractors = new ArrayList(); + setOfContractors.add( contractor1 ); + setOfContractors.add( contractor2 ); + employer.setContractors( setOfContractors ); + + // add employer to contractors + Collection employerListContractor1 = new ArrayList(); + employerListContractor1.add( employer ); + contractor1.setEmployers( employerListContractor1 ); + + Collection employerListContractor2 = new ArrayList(); + employerListContractor2.add( employer ); + contractor2.setEmployers( employerListContractor2 ); + + s.flush(); + s.clear(); + + // assertions + employer = (Employer) s.get( Employer.class, employer.getId() ); + assertNotNull( employer ); + assertNotNull( employer.getContractors() ); + assertEquals( 2, employer.getContractors().size() ); + Contractor firstContractorFromDb = (Contractor) employer.getContractors().iterator().next(); + assertEquals( contractor2.getName(), firstContractorFromDb.getName() ); + tx.rollback(); + s.close(); + } + @Test public void testRemoveInBetween() throws Exception { Session s; From 7e0559ecdbfbb985b412ac5d4ea367f2e8995226 Mon Sep 17 00:00:00 2001 From: John Hardin Date: Wed, 29 Aug 2012 16:00:28 -0500 Subject: [PATCH 35/38] HHH-7398 -- Added testTimeout() and modified AbstractBatchImpl.buildBatchStatement() accordingly. --- .../batch/internal/AbstractBatchImpl.java | 14 +------- .../test/interceptor/InterceptorTest.java | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 13 deletions(-) mode change 100644 => 100755 hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/AbstractBatchImpl.java diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/AbstractBatchImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/AbstractBatchImpl.java old mode 100644 new mode 100755 index b1807e9cec..1edeab7fd4 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/AbstractBatchImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/AbstractBatchImpl.java @@ -135,19 +135,7 @@ public abstract class AbstractBatchImpl implements Batch { } private PreparedStatement buildBatchStatement(String sql, boolean callable) { - sql = jdbcCoordinator.getTransactionCoordinator().getTransactionContext().onPrepareStatement( sql ); - try { - if ( callable ) { - return jdbcCoordinator.getLogicalConnection().getShareableConnectionProxy().prepareCall( sql ); - } - else { - return jdbcCoordinator.getLogicalConnection().getShareableConnectionProxy().prepareStatement( sql ); - } - } - catch ( SQLException sqle ) { - LOG.sqlExceptionEscapedProxy( sqle ); - throw sqlExceptionHelper().convert( sqle, "could not prepare batch statement", sql ); - } + return jdbcCoordinator.getStatementPreparer().prepareStatement( sql, callable ); } @Override diff --git a/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java b/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java index c8cd78ad28..cb354833cd 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java @@ -34,6 +34,7 @@ import org.hibernate.EmptyInterceptor; import org.hibernate.Interceptor; import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.TransactionException; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.type.Type; @@ -43,6 +44,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * @author Gavin King @@ -132,6 +134,40 @@ public class InterceptorTest extends BaseCoreFunctionalTestCase { } + /** + * Test that setting a transaction timeout will cause an Exception to occur + * if the transaction timeout is exceeded. + */ + @Test + public void testTimeout() throws Exception { + final int TIMEOUT = 2; + final int WAIT = TIMEOUT + 1; + Session s = openSession(); + // Get the transaction and set the timeout BEFORE calling begin() + Transaction t = s.getTransaction(); + t.setTimeout( TIMEOUT ); + t.begin(); + // Sleep for an amount of time that exceeds the transaction timeout + Thread.sleep( WAIT * 1000 ); + try { + // Do something with the transaction and try to commit it + s.persist( new User( "john", "test" ) ); + t.commit(); + fail( "Transaction should have timed out" ); + } + catch ( TransactionException e ) { + // Insure that the Exception is "transaction timeout expired" + String exceptionActual = e.toString(); + String exceptionExpected = "org.hibernate.TransactionException: transaction timeout expired"; + if ( !exceptionActual.contains( exceptionExpected ) ) { + String msg = String.format( "Transaction failed for the wrong reason. Expected [%s] but received [%s]", + exceptionExpected, exceptionActual ); + fail( msg ); + + } + } + } + @Test public void testComponentInterceptor() { final int checkPerm = 500; From 094c08cd087cdfff1b3909e10a1a95581ec75068 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Thu, 6 Sep 2012 08:41:37 -0500 Subject: [PATCH 36/38] HHH-7575 - Hibernate Getting Started Guide refers to incorrect tutorial directory for annotations tutoral --- .../quickstart/en-US/content/tutorial_annotations.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/documentation/src/main/docbook/quickstart/en-US/content/tutorial_annotations.xml b/documentation/src/main/docbook/quickstart/en-US/content/tutorial_annotations.xml index 0a551a950c..f10aa99caf 100644 --- a/documentation/src/main/docbook/quickstart/en-US/content/tutorial_annotations.xml +++ b/documentation/src/main/docbook/quickstart/en-US/content/tutorial_annotations.xml @@ -4,7 +4,7 @@ Tutorial Using Native Hibernate APIs and Annotation Mappings - This tutorial is located within the download bundle under basic. + This tutorial is located within the download bundle under annotations. Objectives @@ -55,8 +55,7 @@ public class Event { It functions the same as the class mapping element discussed in . Additionally the @javax.persistence.Table annotation explicitly specifies the table - name. Without this specification, the default table name would be EVENT). + name. Without this specification, the default table name would be EVENT). From e9bd0afe8105573740d85a1a6634d0c6ab4fc39f Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Fri, 7 Sep 2012 12:01:41 -0500 Subject: [PATCH 37/38] HHH-1658 - unexpected AST node on HQL UPDATE --- .../org/hibernate/test/hql/BulkManipulationTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hibernate-core/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java b/hibernate-core/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java index 64c8514c3e..f808753a17 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java @@ -69,6 +69,18 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase { }; } + @Test + public void testUpdateWithSubquery() { + Session s = openSession(); + s.beginTransaction(); + + // just checking parsing and syntax... + s.createQuery( "update Human h set h.bodyWeight = h.bodyWeight + (select count(1) from IntegerVersioned)" ).executeUpdate(); + + s.getTransaction().commit(); + s.close(); + } + @Test public void testDeleteNonExistentEntity() { Session s = openSession(); From 7b486fc4a4742d9c3fb01c1a4ec613e444d52ede Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Fri, 7 Sep 2012 12:03:48 -0500 Subject: [PATCH 38/38] HHH-1658 - unexpected AST node on HQL UPDATE --- .../test/java/org/hibernate/test/hql/BulkManipulationTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hibernate-core/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java b/hibernate-core/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java index f808753a17..28a291791a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java @@ -76,6 +76,7 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase { // just checking parsing and syntax... s.createQuery( "update Human h set h.bodyWeight = h.bodyWeight + (select count(1) from IntegerVersioned)" ).executeUpdate(); + s.createQuery( "update Human h set h.bodyWeight = h.bodyWeight + (select count(1) from IntegerVersioned) where h.description = 'abc'" ).executeUpdate(); s.getTransaction().commit(); s.close();