diff --git a/hibernate-core/src/main/java/org/hibernate/LockOptions.java b/hibernate-core/src/main/java/org/hibernate/LockOptions.java index c9659998a588..c90feab563fd 100644 --- a/hibernate-core/src/main/java/org/hibernate/LockOptions.java +++ b/hibernate-core/src/main/java/org/hibernate/LockOptions.java @@ -465,7 +465,7 @@ public Boolean getFollowOnLocking() { * @return {@code this} for method chaining * * @see org.hibernate.jpa.HibernateHints#HINT_FOLLOW_ON_LOCKING - * @see org.hibernate.dialect.Dialect#useFollowOnLocking(String, QueryOptions) + * @see org.hibernate.dialect.Dialect#useFollowOnLocking(String, org.hibernate.query.spi.QueryOptions) */ public LockOptions setFollowOnLocking(Boolean followOnLocking) { if ( immutable ) { 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 20b099bd5e5a..ed3114038465 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -4156,7 +4156,7 @@ public boolean isEmptyStringTreatedAsNull() { * {@code false} (the default) indicates that locking * should be applied to the main SQL statement. * - * @since 5.2 + * @since 6.0 */ public boolean useFollowOnLocking(String sql, QueryOptions queryOptions) { return false; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/naming/NamingHelperTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/naming/NamingHelperTest.java index 66180747a14c..d71d46cd6b6a 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/naming/NamingHelperTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/naming/NamingHelperTest.java @@ -6,45 +6,86 @@ import org.hibernate.boot.model.naming.Identifier; import org.hibernate.boot.model.naming.NamingHelper; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -import org.hibernate.testing.orm.junit.JiraKey; -import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.junit.Test; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; -public class NamingHelperTest extends BaseUnitTestCase { +class NamingHelperTest { - @Test - @JiraKey(value = "HHH-12357") - public void generateHashedFkName() { - Identifier booksDe = new Identifier( "Bücher", false ); - Identifier authorsDe = new Identifier( "Autoren", false ); - Identifier authorId = new Identifier( "autor_id", false ); + @ParameterizedTest + @MethodSource("args") + void smoke(String charset, String prefix, String tableName, String referencedTableName, List columnNames, String expectedFkName, String expectedConstraintName) { + assertThat( NamingHelper.withCharset( charset ) + .generateHashedFkName( + prefix, + Identifier.toIdentifier( tableName ), + Identifier.toIdentifier( referencedTableName ), + columnNames.stream().map( Identifier::toIdentifier ) + .collect( Collectors.toUnmodifiableList() ) ) ) + .isEqualTo( expectedFkName ); - String fkNameLatin1 = NamingHelper.withCharset( "ISO-8859-1" ).generateHashedFkName( "FK", booksDe, authorsDe, authorId ); + assertThat( NamingHelper.withCharset( charset ) + .generateHashedFkName( + prefix, + Identifier.toIdentifier( tableName ), + Identifier.toIdentifier( referencedTableName ), + columnNames.stream().map( Identifier::toIdentifier ) + .toArray( Identifier[]::new ) ) ) + .isEqualTo( expectedFkName ); - assertEquals( "FKpvm24wh1qwbmx6xjcbc7uv5f7", fkNameLatin1 ); + assertThat( NamingHelper.withCharset( charset ) + .generateHashedConstraintName( + prefix, + Identifier.toIdentifier( tableName ), + columnNames.stream().map( Identifier::toIdentifier ) + .collect( Collectors.toUnmodifiableList() ) ) ) + .isEqualTo( expectedConstraintName ); - String fkNameUtf8 = NamingHelper.withCharset( "UTF8" ).generateHashedFkName( "FK", booksDe, authorsDe, authorId ); - - assertEquals( "FKdgopp1hqnm8c1o6sfbb3tbeh", fkNameUtf8 ); + assertThat( NamingHelper.withCharset( charset ) + .generateHashedConstraintName( + prefix, + Identifier.toIdentifier( tableName ), + columnNames.stream().map( Identifier::toIdentifier ) + .toArray( Identifier[]::new ) ) ) + .isEqualTo( expectedConstraintName ); } - @Test - @JiraKey(value = "HHH-12357") - public void generateHashedFkNameUSingUtf8() { - Identifier booksDe = new Identifier( "Bücher", false ); - Identifier authorsDe = new Identifier( "Autoren", false ); - Identifier authorId = new Identifier( "autor_id", false ); - - String fkNameLatin1 = NamingHelper.withCharset( "UTF8" ).generateHashedFkName( "FK", booksDe, authorsDe, authorId ); - - assertEquals( "FKdgopp1hqnm8c1o6sfbb3tbeh", fkNameLatin1 ); - - String fkNameUtf8 = NamingHelper.withCharset( "UTF8" ).generateHashedFkName( "FK", booksDe, authorsDe, authorId ); - - assertEquals( "FKdgopp1hqnm8c1o6sfbb3tbeh", fkNameUtf8 ); + private static Stream args() { + // String charset, String prefix, String tableName, String referencedTableName, + // List columnNames, String expectedFkName, String expectedConstraintName + return Stream.of( + Arguments.of( + StandardCharsets.UTF_8.name(), + "fk_", "table_name", "other_table_name", List.of( "col1", "col2", "col3" ), + "fk_f4u43ook9b825fxbm3exb18q6", "fk_1o8k3sa4q2a2wb596v4htt8qf" ), + Arguments.of( + StandardCharsets.ISO_8859_1.name(), + "fk_", "table_name", "other_table_name", List.of( "col1", "col2", "col3" ), + "fk_f4u43ook9b825fxbm3exb18q6", "fk_1o8k3sa4q2a2wb596v4htt8qf" ), + Arguments.of( + StandardCharsets.UTF_8.name(), + "fk_", "café", "le_déjeuner", List.of( "col1", "col2", "col3" ), + "fk_jdvsrk14lxab6a829ok160vyj", "fk_h34kugb2bguwmcn1g5h1q3snf" ), + Arguments.of( + StandardCharsets.ISO_8859_1.name(), + "fk_", "café", "le_déjeuner", List.of( "col1", "col2", "col3" ), + "fk_g1py0mkjd1tu46tr8c2e1vm2l", "fk_1pitt5gtytwpy6ea02o7l5men" ), + Arguments.of( + StandardCharsets.UTF_8.name(), + "fk_", "abcdefghijklmnopqrstuvwxyzäöüß", "stuvwxyzäöüß", List.of( "col1" ), + "fk_q11mlivmrc3sdfnncd2hwkpqp", "fk_gm8xsqu7ayucv5w5w2gj2dfly" ), + Arguments.of( + StandardCharsets.ISO_8859_1.name(), + "fk_", "abcdefghijklmnopqrstuvwxyzäöüß", "stuvwxyzäöüß", List.of( "col1" ) + , "fk_fua9hgc6dn6eno8hlqt58j72o", "fk_3iig3yrgsf5bjlbdo05d7mp2" ) + ); } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/inheritance/discriminator/PersistChildEntitiesWithDiscriminatorTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/inheritance/discriminator/PersistChildEntitiesWithDiscriminatorTest.java deleted file mode 100644 index 5d6c5e670981..000000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/inheritance/discriminator/PersistChildEntitiesWithDiscriminatorTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-2.1-or-later - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.orm.test.inheritance.discriminator; - -import org.hibernate.dialect.PostgreSQLDialect; - -import org.hibernate.testing.orm.junit.JiraKey; -import org.hibernate.testing.orm.junit.DomainModel; -import org.hibernate.testing.orm.junit.RequiresDialect; -import org.hibernate.testing.orm.junit.SessionFactory; -import org.hibernate.testing.orm.junit.SessionFactoryScope; -import org.hibernate.orm.test.mapping.inheritance.discriminator.InheritingEntity; -import org.hibernate.orm.test.mapping.inheritance.discriminator.ParentEntity; -import org.junit.jupiter.api.Test; - -/** - * @author Pawel Stawicki - */ -@SessionFactory -@RequiresDialect(value = PostgreSQLDialect.class) -@DomainModel(annotatedClasses = { - ParentEntity.class, InheritingEntity.class -}) -@JiraKey(value = "HHH-6580") -public class PersistChildEntitiesWithDiscriminatorTest { - - @Test - public void doIt(SessionFactoryScope scope) { - scope.inTransaction( - session -> { - // we need the 2 inserts so that the id is incremented on the second get-generated-keys-result set, since - // on the first insert both the pk and the discriminator values are 1 - session.persist( new InheritingEntity( "yabba" ) ); - session.persist( new InheritingEntity( "dabba" ) ); - } - ); - - scope.inTransaction( - session -> { - session.createQuery( "delete ParentEntity", null ).executeUpdate(); - - } - ); - } - -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/inheritance/discriminator/InheritingEntity.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/inheritance/discriminator/InheritingEntity.java deleted file mode 100644 index f9a1b3ddb2ec..000000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/inheritance/discriminator/InheritingEntity.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-2.1-or-later - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.orm.test.mapping.inheritance.discriminator; - -import jakarta.persistence.Column; -import jakarta.persistence.DiscriminatorValue; -import jakarta.persistence.Entity; - -/** - * @author Pawel Stawicki - */ -@Entity -@DiscriminatorValue("1") -public class InheritingEntity extends ParentEntity { - public InheritingEntity() { - } - - public InheritingEntity(String someValue) { - this.someValue = someValue; - } - - @Column(name = "dupa") - private String someValue; - - public String getSomeValue() { - return someValue; - } - - public void setSomeValue(String someValue) { - this.someValue = someValue; - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/inheritance/discriminator/ParentEntity.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/inheritance/discriminator/ParentEntity.java deleted file mode 100644 index fb4784989c5f..000000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/inheritance/discriminator/ParentEntity.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-2.1-or-later - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.orm.test.mapping.inheritance.discriminator; - -import jakarta.persistence.Column; -import jakarta.persistence.DiscriminatorColumn; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import jakarta.persistence.Inheritance; - -import static jakarta.persistence.DiscriminatorType.INTEGER; -import static jakarta.persistence.GenerationType.IDENTITY; -import static jakarta.persistence.InheritanceType.SINGLE_TABLE; - -/** - * @author Pawel Stawicki - */ -@Entity -@Inheritance(strategy = SINGLE_TABLE) -@DiscriminatorColumn(name = "CLASS_ID", discriminatorType = INTEGER) -public abstract class ParentEntity { - - @Id - @GeneratedValue(strategy = IDENTITY) - @Column(name = "ajdik") - private Long id; - - public Long getId() { - return id; - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/nonpkassociation/NonPkManyToOneAssociationHbmTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/nonpkassociation/NonPkManyToOneAssociationHbmTest.java deleted file mode 100644 index b6ad1acf10ae..000000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/nonpkassociation/NonPkManyToOneAssociationHbmTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-2.1-or-later - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.orm.test.nonpkassociation; - -import java.util.HashSet; -import java.util.Set; - -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.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - - -/** - * @author pholvs - */ -@DomainModel( - xmlMappings = "org/hibernate/orm/test/nonpkassociation/NonPkManyToOneAssociationHbmTest.hbm.xml" -) -@SessionFactory -public class NonPkManyToOneAssociationHbmTest { - - private Parent parent; - - @BeforeEach - public void createTestData(SessionFactoryScope scope) { - scope.inTransaction( - s -> { - parent = new Parent( 99999L ); - s.persist( parent ); - - Child c = new Child( parent ); - parent.getChildren().add( c ); - c.setParent( parent ); - } - ); - } - - @AfterEach - public void tearDown(SessionFactoryScope scope){ - scope.inTransaction( - session -> { - session.createQuery( "delete from NonPkManyToOneAssociationHbmTest$Child" ).executeUpdate(); - session.createQuery( "delete from NonPkManyToOneAssociationHbmTest$Parent" ).executeUpdate(); - } - ); - } - - - @Test - public void testHqlWithFetch(SessionFactoryScope scope) { - scope.inTransaction( - s -> { - Parent dbParent = s.find( Parent.class, this.parent.getId() ); - Set children = dbParent.getChildren(); - assertEquals( 1, children.size() ); - } - ); - } - - public static class Parent { - private Long id; - - private Long collectionKey; - - private Set children = new HashSet<>(); - - public Parent(Long collectionKey) { - setCollectionKey( collectionKey ); - } - - Parent() { - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getCollectionKey() { - return collectionKey; - } - - public void setCollectionKey(Long collectionKey) { - this.collectionKey = collectionKey; - } - - public Set getChildren() { - return children; - } - - public void setChildren(Set children) { - this.children = children; - } - } - - public static class Child { - - private Long id; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - private String name; - - private Parent parent; - - public Child(Parent parent) { - setParent( parent ); - } - - Child() { - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Parent getParent() { - return parent; - } - - public void setParent(Parent parent) { - this.parent = parent; - } - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/nonpkassociation/NonPkManyToOneAssociationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/nonpkassociation/NonPkManyToOneAssociationTest.java deleted file mode 100644 index 52ae75911067..000000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/nonpkassociation/NonPkManyToOneAssociationTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-2.1-or-later - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.orm.test.nonpkassociation; - -import java.io.Serializable; -import java.util.HashSet; -import java.util.Set; -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; - -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.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.Assert.assertEquals; - -/** - * @author pholvs - */ -@DomainModel( - annotatedClasses = { - NonPkManyToOneAssociationTest.Parent.class, - NonPkManyToOneAssociationTest.Child.class, - } -) -@SessionFactory -public class NonPkManyToOneAssociationTest { - private Parent parent; - - @BeforeEach - public void createTestData(SessionFactoryScope scope) { - scope.inTransaction( - s -> { - parent = new Parent( 99999L ); - s.persist( parent ); - - Child c = new Child( parent ); - parent.getChildren().add( c ); - c.setParent( parent ); - } - ); - } - - @AfterEach - public void tearDown(SessionFactoryScope scope) { - scope.inTransaction( - session -> { - session.createQuery( "delete from Child" ).executeUpdate(); - session.createQuery( "delete from Parent" ).executeUpdate(); - } - ); - } - - - @Test - public void testHqlWithFetch(SessionFactoryScope scope) { - scope.inTransaction( - s -> { - Parent parent = s.find( Parent.class, this.parent.getId() ); - assertEquals( 1, parent.getChildren().size() ); - } - ); - } - - @Entity(name = "Parent") - public static class Parent implements Serializable { - - @Id - @GeneratedValue - private Long id; - - private Long collectionKey; - - @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL) - private Set children = new HashSet<>(); - - public Parent(Long collectionKey) { - setCollectionKey( collectionKey ); - } - - Parent() { - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getCollectionKey() { - return collectionKey; - } - - public void setCollectionKey(Long collectionKey) { - this.collectionKey = collectionKey; - } - - public Set getChildren() { - return children; - } - - public void setChildren(Set children) { - this.children = children; - } - } - - @Entity(name = "Child") - public static class Child { - - @Id - @GeneratedValue - private Long id; - - private String name; - - @ManyToOne - @JoinColumn(name = "parentVal", referencedColumnName = "collectionKey") - private Parent parent; - - public Child(Parent parent) { - setParent( parent ); - } - - Child() { - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Parent getParent() { - return parent; - } - - public void setParent(Parent parent) { - this.parent = parent; - } - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/pagination/OraclePaginationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/pagination/OraclePaginationTest.java deleted file mode 100644 index 74390f4532b0..000000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/pagination/OraclePaginationTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-2.1-or-later - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.orm.test.pagination; - -import java.io.Serializable; -import java.util.List; -import jakarta.persistence.Entity; -import jakarta.persistence.EntityManager; -import jakarta.persistence.Id; -import jakarta.persistence.Table; -import jakarta.persistence.TypedQuery; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.CriteriaQuery; -import jakarta.persistence.criteria.Root; - -import org.hibernate.dialect.OracleDialect; -import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; - -import org.hibernate.testing.RequiresDialect; -import org.hibernate.testing.orm.junit.JiraKey; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; -import static org.junit.Assert.assertEquals; - -/** - * @author Vlad Mihalcea - */ -@RequiresDialect(OracleDialect.class) -public class OraclePaginationTest extends BaseEntityManagerFunctionalTestCase { - - @Override - protected Class[] getAnnotatedClasses() { - return new Class[] { - RootEntity.class, - }; - } - - @Before - public void setUp() { - doInJPA( this::entityManagerFactory, entityManager -> { - entityManager.persist( new RootEntity( 1L, 7L, "t40", 2L ) ); - entityManager.persist( new RootEntity( 16L, 1L, "t47", 2L ) ); - entityManager.persist( new RootEntity( 11L, 2L, "t43", 2L ) ); - entityManager.persist( new RootEntity( 6L, 4L, "t31", 2L ) ); - entityManager.persist( new RootEntity( 15L, 1L, "t46", 2L ) ); - entityManager.persist( new RootEntity( 2L, 6L, "t39", 2L ) ); - entityManager.persist( new RootEntity( 14L, 1L, "t45", 2L ) ); - entityManager.persist( new RootEntity( 4L, 5L, "t38", 2L ) ); - entityManager.persist( new RootEntity( 8L, 2L, "t29", 2L ) ); - entityManager.persist( new RootEntity( 17L, 1L, "t48", 2L ) ); - entityManager.persist( new RootEntity( 3L, 3L, "t21", 2L ) ); - entityManager.persist( new RootEntity( 7L, 2L, "t23", 2L ) ); - entityManager.persist( new RootEntity( 9L, 2L, "t30", 2L ) ); - entityManager.persist( new RootEntity( 10L, 3L, "t42", 2L ) ); - entityManager.persist( new RootEntity( 12L, 1L, "t41", 2L ) ); - entityManager.persist( new RootEntity( 5L, 6L, "t37", 1L ) ); - entityManager.persist( new RootEntity( 13L, 1L, "t44", 1L ) ); - } ); - } - - @After - public void tearDown() { - doInJPA( this::entityManagerFactory, entityManager -> { - entityManager.createQuery( "delete from RootEntity" ).executeUpdate(); - } ); - } - - - @Test - @JiraKey(value = "HHH-12087") - public void testPagination() { - doInJPA( this::entityManagerFactory, entityManager -> { - List rootEntitiesAllPages = getLimitedRows( entityManager, 0, 10 ); - - List rootEntitiesFirst = getLimitedRows( entityManager, 0, 5 ); - assertEquals( 5, rootEntitiesFirst.size() ); - List rootEntitiesSecond = getLimitedRows( entityManager, 5, 10 ); - assertEquals( 10, rootEntitiesSecond.size() ); - - assertEquals( rootEntitiesAllPages.get( 0 ).getId(), rootEntitiesFirst.get( 0 ).getId() ); - assertEquals( rootEntitiesAllPages.get( 1 ).getId(), rootEntitiesFirst.get( 1 ).getId() ); - assertEquals( rootEntitiesAllPages.get( 2 ).getId(), rootEntitiesFirst.get( 2 ).getId() ); - assertEquals( rootEntitiesAllPages.get( 3 ).getId(), rootEntitiesFirst.get( 3 ).getId() ); - assertEquals( rootEntitiesAllPages.get( 4 ).getId(), rootEntitiesFirst.get( 4 ).getId() ); - - assertEquals( rootEntitiesAllPages.get( 5 ).getId(), rootEntitiesSecond.get( 0 ).getId() ); - assertEquals( rootEntitiesAllPages.get( 6 ).getId(), rootEntitiesSecond.get( 1 ).getId() ); - assertEquals( rootEntitiesAllPages.get( 7 ).getId(), rootEntitiesSecond.get( 2 ).getId() ); - assertEquals( rootEntitiesAllPages.get( 8 ).getId(), rootEntitiesSecond.get( 3 ).getId() ); - assertEquals( rootEntitiesAllPages.get( 9 ).getId(), rootEntitiesSecond.get( 4 ).getId() ); - } ); - } - - @Test - public void testPaginationWithSetMaxResultsOnly() { - doInJPA( this::entityManagerFactory, entityManager -> { - CriteriaBuilder cb = entityManager.getCriteriaBuilder(); - CriteriaQuery cq = cb.createQuery( RootEntity.class ); - Root c = cq.from( RootEntity.class ); - CriteriaQuery select = cq.select( c ).orderBy( cb.desc( c.get( "status" ) ) ); - TypedQuery typedQuery = entityManager.createQuery( select ); - typedQuery.setMaxResults( 10 ); - List resultList = typedQuery.getResultList(); - assertEquals( 10, resultList.size() ); - } ); - } - - private List getAllRows(EntityManager em) { - CriteriaBuilder cb = em.getCriteriaBuilder(); - CriteriaQuery cq = cb.createQuery( RootEntity.class ); - Root c = cq.from( RootEntity.class ); - return em.createQuery( cq.select( c ).orderBy( cb.desc( c.get( "status" ) ) ) ).getResultList(); - } - - private List getLimitedRows(EntityManager em, int start, int end) { - CriteriaBuilder cb = em.getCriteriaBuilder(); - CriteriaQuery cq = cb.createQuery( RootEntity.class ); - Root c = cq.from( RootEntity.class ); - CriteriaQuery select = cq.select( c ).orderBy( cb.desc( c.get( "status" ) ) ); - TypedQuery typedQuery = em.createQuery( select ); - typedQuery.setFirstResult( start ); - typedQuery.setMaxResults( end ); - return typedQuery.getResultList(); - } - - @Entity(name = "RootEntity") - @Table(name = "V_MYTABLE_LAST") - public static class RootEntity implements Serializable { - - @Id - private Long id; - - @Id - private Long version; - - private String caption; - - private Long status; - - public RootEntity() { - } - - public RootEntity(Long id, Long version, String caption, Long status) { - this.id = id; - this.version = version; - this.caption = caption; - this.status = status; - } - - public Long getId() { - return id; - } - } - -} diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/nonpkassociation/NonPkManyToOneAssociationHbmTest.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/nonpkassociation/NonPkManyToOneAssociationHbmTest.hbm.xml deleted file mode 100644 index 716c9b105696..000000000000 --- a/hibernate-core/src/test/resources/org/hibernate/orm/test/nonpkassociation/NonPkManyToOneAssociationHbmTest.hbm.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/util/ReflectionUtil.java b/hibernate-testing/src/main/java/org/hibernate/testing/util/ReflectionUtil.java index 07434a468806..82b2eeb7a0a2 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/util/ReflectionUtil.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/util/ReflectionUtil.java @@ -63,24 +63,6 @@ public static T getFieldValue(Object target, String name) { } } - /** - * Get a field value from a given class - * - * @param target Class whose field is being read - * @param name field name - * - * @return field value - */ - public static T getStaticFieldValue(Class target, String name) { - try { - Field field = getField( target, name ); - return (T) field.get( null ); - } - catch (IllegalAccessException e) { - throw new IllegalArgumentException( "Cannot set field " + name, e ); - } - } - /** * Set target Object field to a certain value *