From b520752c8d0cff59adbfdecc2cbede422e786863 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 10 Nov 2021 09:04:31 +0100 Subject: [PATCH] Fix issue with class used as IdClass and also embedded in another IdClass --- .../internal/ToOneAttributeMapping.java | 28 +++++++- .../derivedidentities/e2/a/Dependent.java | 2 +- .../derivedidentities/e2/a/DependentId.java | 2 +- ...edIdentityIdClassParentIdClassDepTest.java | 71 +++++++++++++++++++ .../derivedidentities/e2/a/Employee.java | 2 +- .../derivedidentities/e2/a/EmployeeId.java | 2 +- .../annotations/embeddables/DollarValue.java | 2 +- .../embeddables/DollarValueUserType.java | 2 +- .../embeddables/EmbeddableIntegratorTest.java | 59 +++++++++------ .../annotations/embeddables/Investment.java | 2 +- .../annotations/embeddables/Investor.java | 2 +- .../embeddables/InvestorTypeContributor.java | 2 +- .../test/annotations/embeddables/MyDate.java | 2 +- .../embeddables/MyDateUserType.java | 2 +- ...edIdentityIdClassParentIdClassDepTest.java | 65 ----------------- 15 files changed, 146 insertions(+), 99 deletions(-) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/derivedidentities/e2/a/Dependent.java (92%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/derivedidentities/e2/a/DependentId.java (88%) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/DerivedIdentityIdClassParentIdClassDepTest.java rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/derivedidentities/e2/a/Employee.java (87%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/derivedidentities/e2/a/EmployeeId.java (85%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/embeddables/DollarValue.java (91%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/embeddables/DollarValueUserType.java (97%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/embeddables/EmbeddableIntegratorTest.java (61%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/embeddables/Investment.java (94%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/embeddables/Investor.java (94%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/embeddables/InvestorTypeContributor.java (93%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/embeddables/MyDate.java (91%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/embeddables/MyDateUserType.java (97%) delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/DerivedIdentityIdClassParentIdClassDepTest.java diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java index 7e2ef8cb86..c43be4cecf 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java @@ -67,6 +67,7 @@ import org.hibernate.sql.ast.tree.from.LazyTableGroup; import org.hibernate.sql.ast.tree.from.MappedByTableGroup; import org.hibernate.sql.ast.tree.from.PluralTableGroup; import org.hibernate.sql.ast.tree.from.StandardTableGroup; +import org.hibernate.sql.ast.tree.from.StandardVirtualTableGroup; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroupJoin; import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer; @@ -79,6 +80,7 @@ import org.hibernate.sql.results.graph.Fetch; import org.hibernate.sql.results.graph.FetchOptions; import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable; +import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableFetchImpl; import org.hibernate.sql.results.graph.entity.EntityFetch; import org.hibernate.sql.results.graph.entity.EntityValuedFetchable; import org.hibernate.sql.results.graph.entity.internal.EntityDelayedFetchImpl; @@ -995,6 +997,29 @@ public class ToOneAttributeMapping tableGroup = tableGroupJoin.getJoinedGroup(); fromClauseAccess.registerTableGroup( fetchablePath, tableGroup ); } + else if ( fetchParent instanceof EmbeddableFetchImpl ) { + final TableGroup existingTableGroup = fromClauseAccess.findTableGroup( + fetchablePath + ); + final TableGroupJoin tableGroupJoin = createTableGroupJoin( + fetchablePath, + parentTableGroup, + resultVariable, + getJoinType( fetchablePath, parentTableGroup ), + true, + false, + creationState.getSqlAstCreationState() + ); + final TableGroup joinedGroup = tableGroupJoin.getJoinedGroup(); + if ( existingTableGroup == null || joinedGroup instanceof LazyTableGroup && existingTableGroup instanceof StandardVirtualTableGroup ) { + parentTableGroup.addTableGroupJoin( tableGroupJoin ); + fromClauseAccess.registerTableGroup( fetchablePath, joinedGroup ); + tableGroup = joinedGroup; + } + else { + tableGroup = existingTableGroup; + } + } else { tableGroup = fromClauseAccess.resolveTableGroup( fetchablePath, @@ -1025,7 +1050,7 @@ public class ToOneAttributeMapping ); } } - return new EntityFetchJoinedImpl( + final EntityFetchJoinedImpl entityFetchJoined = new EntityFetchJoinedImpl( fetchParent, this, tableGroup, @@ -1033,6 +1058,7 @@ public class ToOneAttributeMapping fetchablePath, creationState ); + return entityFetchJoined; } /* diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/Dependent.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/Dependent.java similarity index 92% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/Dependent.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/Dependent.java index 1b93889ec6..34cda1ef58 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/Dependent.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/Dependent.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.annotations.derivedidentities.e2.a; +package org.hibernate.orm.test.annotations.derivedidentities.e2.a; import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.IdClass; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/DependentId.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/DependentId.java similarity index 88% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/DependentId.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/DependentId.java index a2a43208d4..e42e4e13b8 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/DependentId.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/DependentId.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.annotations.derivedidentities.e2.a; +package org.hibernate.orm.test.annotations.derivedidentities.e2.a; import java.io.Serializable; import jakarta.persistence.Embedded; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/DerivedIdentityIdClassParentIdClassDepTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/DerivedIdentityIdClassParentIdClassDepTest.java new file mode 100644 index 0000000000..bff5b4d9dd --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/DerivedIdentityIdClassParentIdClassDepTest.java @@ -0,0 +1,71 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.orm.test.annotations.derivedidentities.e2.a; + +import org.hibernate.boot.spi.MetadataImplementor; +import org.hibernate.orm.test.util.SchemaUtil; + +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * @author Emmanuel Bernard + */ +@DomainModel( + annotatedClasses = { + Employee.class, + Dependent.class + } +) +@SessionFactory +public class DerivedIdentityIdClassParentIdClassDepTest { + + @Test + public void testManyToOne(SessionFactoryScope scope) { + final MetadataImplementor metadata = scope.getMetadataImplementor(); + assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", metadata ) ); + assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", metadata ) ); + assertTrue( SchemaUtil.isColumnPresent( "Dependent", "name", metadata ) ); + assertTrue( !SchemaUtil.isColumnPresent( "Dependent", "firstName", metadata ) ); + assertTrue( !SchemaUtil.isColumnPresent( "Dependent", "lastName", metadata ) ); + + Employee e = new Employee(); + e.firstName = "Emmanuel"; + e.lastName = "Bernard"; + + scope.inTransaction( + session -> { + session.persist( e ); + Dependent d = new Dependent(); + d.emp = e; + d.name = "Doggy"; + session.persist( d ); + session.flush(); + session.clear(); + + DependentId dId = new DependentId(); + EmployeeId eId = new EmployeeId(); + dId.name = d.name; + dId.emp = eId; + eId.firstName = e.firstName; + eId.lastName = e.lastName; + d = session.get( Dependent.class, dId ); + assertNotNull( d.emp ); + assertEquals( e.firstName, d.emp.firstName ); + + session.delete( d ); + session.delete( d.emp ); + } + ); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/Employee.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/Employee.java similarity index 87% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/Employee.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/Employee.java index 00787dd5a9..96f270616e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/Employee.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/Employee.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.annotations.derivedidentities.e2.a; +package org.hibernate.orm.test.annotations.derivedidentities.e2.a; import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.IdClass; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/EmployeeId.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/EmployeeId.java similarity index 85% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/EmployeeId.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/EmployeeId.java index 69de7c9932..e4af968c28 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/EmployeeId.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/derivedidentities/e2/a/EmployeeId.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.annotations.derivedidentities.e2.a; +package org.hibernate.orm.test.annotations.derivedidentities.e2.a; import java.io.Serializable; /** diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/DollarValue.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValue.java similarity index 91% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/DollarValue.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValue.java index a7a120c59b..129d7126d2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/DollarValue.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValue.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.annotations.embeddables; +package org.hibernate.orm.test.annotations.embeddables; import java.io.Serializable; import java.math.BigDecimal; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/DollarValueUserType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValueUserType.java similarity index 97% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/DollarValueUserType.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValueUserType.java index 6bfc50dc7d..679405f4e2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/DollarValueUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValueUserType.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.annotations.embeddables; +package org.hibernate.orm.test.annotations.embeddables; import java.io.Serializable; import java.sql.PreparedStatement; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/EmbeddableIntegratorTest.java similarity index 61% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/EmbeddableIntegratorTest.java index 9325f1e628..d717841ae4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/EmbeddableIntegratorTest.java @@ -4,9 +4,8 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.annotations.embeddables; +package org.hibernate.orm.test.annotations.embeddables; -import jakarta.persistence.PersistenceException; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; @@ -18,19 +17,22 @@ import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.dialect.H2Dialect; -import org.hibernate.testing.RequiresDialect; -import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.junit.Test; +import org.hibernate.testing.orm.junit.BaseUnitTest; +import org.hibernate.testing.orm.junit.RequiresDialect; +import org.junit.jupiter.api.Test; -import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import jakarta.persistence.PersistenceException; + +import static org.hibernate.testing.orm.junit.ExtraAssertions.assertTyping; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Chris Pheby */ +@BaseUnitTest @RequiresDialect(H2Dialect.class) -public class EmbeddableIntegratorTest extends BaseUnitTestCase { +public class EmbeddableIntegratorTest { /** * Throws a mapping exception because DollarValue is not mapped @@ -48,16 +50,22 @@ public class EmbeddableIntegratorTest extends BaseUnitTestCase { sess.save( myInv ); sess.flush(); - fail("A JDBCException expected"); + fail( "A JDBCException expected" ); sess.clear(); - Investor inv = (Investor) sess.get( Investor.class, 1L ); + Investor inv = sess.get( Investor.class, 1L ); assertEquals( new BigDecimal( "100" ), inv.getInvestments().get( 0 ).getAmount().getAmount() ); - }catch (PersistenceException e){ - assertTyping(JDBCException.class, e.getCause()); + } + catch (PersistenceException e) { + assertTyping( JDBCException.class, e.getCause() ); sess.getTransaction().rollback(); } + finally { + if ( sess.getTransaction().isActive() ) { + sess.getTransaction().rollback(); + } + } sess.close(); } } @@ -68,22 +76,29 @@ public class EmbeddableIntegratorTest extends BaseUnitTestCase { .registerTypeContributor( new InvestorTypeContributor() ) .setProperty( "hibernate.hbm2ddl.auto", "create-drop" ) .buildSessionFactory(); Session sess = sf.openSession()) { - sess.getTransaction().begin(); - Investor myInv = getInvestor(); - myInv.setId( 2L ); + try { + sess.getTransaction().begin(); + Investor myInv = getInvestor(); + myInv.setId( 2L ); - sess.save( myInv ); - sess.flush(); - sess.clear(); + sess.save( myInv ); + sess.flush(); + sess.clear(); - Investor inv = (Investor) sess.get( Investor.class, 2L ); - assertEquals( new BigDecimal( "100" ), inv.getInvestments().get( 0 ).getAmount().getAmount() ); + Investor inv = sess.get( Investor.class, 2L ); + assertEquals( new BigDecimal( "100" ), inv.getInvestments().get( 0 ).getAmount().getAmount() ); + } + finally { + if ( sess.getTransaction().isActive() ) { + sess.getTransaction().rollback(); + } + } } } private Investor getInvestor() { Investor i = new Investor(); - List investments = new ArrayList(); + List investments = new ArrayList<>(); Investment i1 = new Investment(); i1.setAmount( new DollarValue( new BigDecimal( "100" ) ) ); i1.setDate( new MyDate( new Date() ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/Investment.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/Investment.java similarity index 94% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/Investment.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/Investment.java index 8538371b66..13e3315064 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/Investment.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/Investment.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.annotations.embeddables; +package org.hibernate.orm.test.annotations.embeddables; import jakarta.persistence.Column; import jakarta.persistence.Embeddable; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/Investor.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/Investor.java similarity index 94% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/Investor.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/Investor.java index c90f936dae..1f14b2bc78 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/Investor.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/Investor.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.annotations.embeddables; +package org.hibernate.orm.test.annotations.embeddables; import java.util.ArrayList; import java.util.List; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/InvestorTypeContributor.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/InvestorTypeContributor.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/InvestorTypeContributor.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/InvestorTypeContributor.java index 978a89f0d8..accafe895f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/InvestorTypeContributor.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/InvestorTypeContributor.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.annotations.embeddables; +package org.hibernate.orm.test.annotations.embeddables; import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributor; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/MyDate.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDate.java similarity index 91% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/MyDate.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDate.java index a90f52c508..99d650a907 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/MyDate.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDate.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.annotations.embeddables; +package org.hibernate.orm.test.annotations.embeddables; import java.io.Serializable; import java.util.Date; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/MyDateUserType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDateUserType.java similarity index 97% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/MyDateUserType.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDateUserType.java index c2b48af1e9..6339415a8b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/MyDateUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDateUserType.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.annotations.embeddables; +package org.hibernate.orm.test.annotations.embeddables; import java.io.Serializable; import java.sql.PreparedStatement; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/DerivedIdentityIdClassParentIdClassDepTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/DerivedIdentityIdClassParentIdClassDepTest.java deleted file mode 100644 index 042bb499b7..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e2/a/DerivedIdentityIdClassParentIdClassDepTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.test.annotations.derivedidentities.e2.a; - -import org.hibernate.Session; - -import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; -import org.hibernate.orm.test.util.SchemaUtil; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * @author Emmanuel Bernard - */ -public class DerivedIdentityIdClassParentIdClassDepTest extends BaseNonConfigCoreFunctionalTestCase { - @Test - public void testManytoOne() { - assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", metadata() ) ); - assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", metadata() ) ); - assertTrue( SchemaUtil.isColumnPresent( "Dependent", "name", metadata() ) ); - assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", metadata() ) ); - assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", metadata() ) ); - - Employee e = new Employee(); - e.firstName = "Emmanuel"; - e.lastName = "Bernard"; - Session s = openSession( ); - s.getTransaction().begin(); - s.persist( e ); - Dependent d = new Dependent(); - d.emp = e; - d.name = "Doggy"; - s.persist( d ); - s.flush(); - s.clear(); - DependentId dId = new DependentId(); - EmployeeId eId = new EmployeeId(); - dId.name = d.name; - dId.emp = eId; - eId.firstName = e.firstName; - eId.lastName = e.lastName; - d = (Dependent) s.get( Dependent.class, dId ); - assertNotNull( d.emp ); - assertEquals( e.firstName, d.emp.firstName ); - s.delete( d ); - s.delete( d.emp ); - s.getTransaction().commit(); - s.close(); - } - - @Override - protected Class[] getAnnotatedClasses() { - return new Class[] { - Employee.class, - Dependent.class - }; - } -}