diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/collection/LoadEntityWithElementCollectionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/collection/LoadEntityWithElementCollectionTest.java index 351f369013..0590743fa8 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/collection/LoadEntityWithElementCollectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/collection/LoadEntityWithElementCollectionTest.java @@ -17,12 +17,16 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import jakarta.persistence.CollectionTable; import jakarta.persistence.ElementCollection; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; import jakarta.persistence.OneToMany; import jakarta.persistence.OrderColumn; +import jakarta.persistence.Table; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -170,6 +174,7 @@ public class LoadEntityWithElementCollectionTest { } @Entity(name = "IndexedEntity") + @Table( name = "t_entities" ) public static class IndexedEntity { @Id public Long id; @@ -177,10 +182,12 @@ public class LoadEntityWithElementCollectionTest { public boolean[] serializableArray; @ElementCollection + @CollectionTable( name = "t_array_items", joinColumns = @JoinColumn( name = "entity_fk") ) @OrderColumn public boolean[] elementCollectionArray; @OneToMany(fetch = FetchType.EAGER) + @JoinTable( name = "t_referenced_entities", joinColumns = @JoinColumn( name = "entity_fk") ) public Set indexedEntities; public Long getId() { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/generatedkeys/seqidentity/JoinedSequenceIdentityBatchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/generatedkeys/seqidentity/JoinedSequenceIdentityBatchTest.java deleted file mode 100644 index 21ce265dd3..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/generatedkeys/seqidentity/JoinedSequenceIdentityBatchTest.java +++ /dev/null @@ -1,122 +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.orm.test.generatedkeys.seqidentity; - -import java.io.Serializable; -import java.util.List; -import jakarta.persistence.Column; -import jakarta.persistence.DiscriminatorColumn; -import jakarta.persistence.DiscriminatorType; -import jakarta.persistence.DiscriminatorValue; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.Inheritance; -import jakarta.persistence.InheritanceType; -import jakarta.persistence.PrimaryKeyJoinColumn; -import jakarta.persistence.Table; - -import org.hibernate.annotations.GenericGenerator; -import org.hibernate.annotations.Parameter; -import org.hibernate.cfg.AvailableSettings; -import org.hibernate.dialect.OracleDialect; - -import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.orm.junit.DomainModel; -import org.hibernate.testing.orm.junit.RequiresDialect; -import org.hibernate.testing.orm.junit.ServiceRegistry; -import org.hibernate.testing.orm.junit.SessionFactory; -import org.hibernate.testing.orm.junit.SessionFactoryScope; -import org.hibernate.testing.orm.junit.Setting; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - -@ServiceRegistry( - settings = { - @Setting( name = AvailableSettings.STATEMENT_BATCH_SIZE, value = "5" ), - @Setting( name = AvailableSettings.USE_GET_GENERATED_KEYS, value = "true" ) - } -) -@DomainModel( - annotatedClasses = { - JoinedSequenceIdentityBatchTest.Resource.class, - JoinedSequenceIdentityBatchTest.FolderResource.class - } -) -@SessionFactory -@TestForIssue( jiraKey = "HHH-13365" ) -@RequiresDialect( value = OracleDialect.class, majorVersion = 9 ) -public class JoinedSequenceIdentityBatchTest { - - @Test - public void testInsertAndUpdate(SessionFactoryScope scope) { - scope.inTransaction( - session -> { - FolderResource folder = new FolderResource(); - folder.name = "PARENT"; - session.persist( folder ); - } - ); - - scope.inTransaction( - session -> { - List folderResources = session.createQuery( "from FolderResource" ).getResultList(); - assertEquals( 1, folderResources.size() ); - final FolderResource folderResource = folderResources.get( 0 ); - assertNull( folderResource.description ); - folderResource.description = "A folder resource"; - } - ); - - scope.inTransaction( - session -> { - List folderResources = session.createQuery( "from FolderResource" ).getResultList(); - assertEquals( 1, folderResources.size() ); - final FolderResource folderResource = folderResources.get( 0 ); - assertEquals( "A folder resource", folderResource.description ); - } - ); - } - - @Entity(name = "Resource") - @Inheritance(strategy = InheritanceType.JOINED) - @Table(name = "WORKSPACE_RESOURCE") - @DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING) - public static class Resource { - - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_WORKSPACE_RESOURCE") - @GenericGenerator(name = "SEQ_WORKSPACE_RESOURCE", strategy = "sequence-identity", - parameters = {@Parameter(name = "sequence", value = "SEQ_WORKSPACE_RESOURCE")}) - @Column(name = "ID_WORKSPACE_RESOURCE", nullable = false, precision = 18) - private Long id; - - @Column(name = "NAME", nullable = false, length = 256) - protected String name; - - @Column(name = "RESOURCE_TYPE", nullable = false, length = 20) - protected String type; - } - - @Entity(name = "FolderResource") - @Table(name = "WORKSPACE_RESOURCE_FOLDER") - @PrimaryKeyJoinColumn(name = "ID_WORKSPACE_RESOURCE_FOLDER") - @DiscriminatorValue("FOLDER") - public static class FolderResource extends Resource implements Serializable { - private String description; - - public FolderResource() - { - super(); - type = "FOLDER"; - } - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/generatedkeys/seqidentity/MyEntity.hbm.xml b/hibernate-core/src/test/java/org/hibernate/orm/test/generatedkeys/seqidentity/MyEntity.hbm.xml deleted file mode 100644 index fd9b6aa10a..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/generatedkeys/seqidentity/MyEntity.hbm.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/generatedkeys/seqidentity/MyEntity.java b/hibernate-core/src/test/java/org/hibernate/orm/test/generatedkeys/seqidentity/MyEntity.java deleted file mode 100644 index f49e044617..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/generatedkeys/seqidentity/MyEntity.java +++ /dev/null @@ -1,35 +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.orm.test.generatedkeys.seqidentity; - - -/** - * @author Steve Ebersole - */ -public class MyEntity { - private Long id; - private String name; - - public MyEntity() { - } - - public MyEntity(String name) { - this.name = name; - } - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/generatedkeys/seqidentity/SequenceIdentityTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/generatedkeys/seqidentity/SequenceIdentityTest.java deleted file mode 100644 index 8cbcb8f146..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/generatedkeys/seqidentity/SequenceIdentityTest.java +++ /dev/null @@ -1,55 +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.orm.test.generatedkeys.seqidentity; - -import org.hibernate.cfg.Environment; -import org.hibernate.dialect.OracleDialect; - -import org.hibernate.testing.orm.junit.DomainModel; -import org.hibernate.testing.orm.junit.RequiresDialect; -import org.hibernate.testing.orm.junit.ServiceRegistry; -import org.hibernate.testing.orm.junit.SessionFactory; -import org.hibernate.testing.orm.junit.SessionFactoryScope; -import org.hibernate.testing.orm.junit.Setting; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -/** - * @author Steve Ebersole - */ -@ServiceRegistry( - settings = { - //this test makes no sense w/o the following property enabled - //note : this property is set to false by default in Oracle9iDialect - //but if this property is set to false, then the AssertionFailure will - //be thrown by {@link org.hibernate.engine.jdbc.internal.StatementPreparerImpl.checkAutoGeneratedKeysSupportEnabled()} - //so let just change this here and this should be invested deeper. - @Setting( name = Environment.USE_GET_GENERATED_KEYS, value = "true") - } -) -@DomainModel( - xmlMappings = "org/hibernate/orm/test/generatedkeys/seqidentity/MyEntity.hbm.xml" -) -@SessionFactory -@RequiresDialect(value = OracleDialect.class, majorVersion = 9) -public class SequenceIdentityTest { - - @Test - public void testSequenceIdentityGenerator(SessionFactoryScope scope) { - scope.inTransaction( - session -> { - MyEntity e = new MyEntity( "entity-1" ); - session.save( e ); - - // this insert should happen immediately! - assertNotNull( e.getId(), "id not generated through forced insertion" ); - - session.delete( e ); - } - ); - } -}