From a4b574e826dd95bd139ce9f3d5cc267ba8d20975 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 14 Dec 2021 14:34:03 +0100 Subject: [PATCH] @FailureExpected annotation added to tests in orm 6 substituted with @NotImplementedYet --- .../entity/BasicHibernateAnnotationsTest.java | 5 +- .../PluralEmbeddedOverrideTests.java | 3 +- .../TablePerClassOverrideTests.java | 3 +- .../entitygraph/ast/LoadPlanBuilderTest.java | 3 +- .../basic/BasicCriteriaUsageTest.java | 2 + .../orm/test/jpa/query/CachedQueryTest.java | 236 ++++++++++-------- .../test/loading/multiLoad/MultiLoadTest.java | 7 +- .../query/hql/size/ManyToManySizeTest2.java | 25 +- .../query/sqm/exec/DiscriminatorTests.java | 3 +- ...ityWithLazyManyToOneSelfReferenceTest.java | 3 +- .../EntityWithManyToOneSelfReferenceTest.java | 3 +- .../sql/hand/custom/db2/DB2CustomSQLTest.java | 2 + .../hand/custom/derby/DerbyCustomSQLTest.java | 2 + .../hand/custom/mysql/MySQLCustomSQLTest.java | 2 + .../custom/oracle/OracleCustomSQLTest.java | 2 + .../sqlserver/SQLServerCustomSQLTest.java | 2 + .../custom/sybase/SybaseCustomSQLTest.java | 2 + 17 files changed, 172 insertions(+), 133 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/entity/BasicHibernateAnnotationsTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/entity/BasicHibernateAnnotationsTest.java index 3848a9eb00..d56c4d33ef 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/entity/BasicHibernateAnnotationsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/entity/BasicHibernateAnnotationsTest.java @@ -589,10 +589,7 @@ public void testSerialized() { } @Test - @FailureExpected( - jiraKey = "", - message = "Support for custom composite types not implemented - org.hibernate.orm.test.annotations.entity.Ransom#getAmount" - ) + @NotImplementedYet(reason = "Support for custom composite types not implemented - org.hibernate.orm.test.annotations.entity.Ransom#getAmount") public void testCompositeType() throws Exception { Session s; Transaction tx; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/attributeOverrides/PluralEmbeddedOverrideTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/attributeOverrides/PluralEmbeddedOverrideTests.java index 0ca7a96ec6..6b8d75b8af 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/attributeOverrides/PluralEmbeddedOverrideTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/attributeOverrides/PluralEmbeddedOverrideTests.java @@ -30,6 +30,7 @@ import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModelScope; import org.hibernate.testing.orm.junit.FailureExpected; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; @@ -91,7 +92,7 @@ public void testModel(DomainModelScope scope) { } @Test - @FailureExpected( reason = "Some problem with NavigablePath creation and/or TableGroup registration under those paths" ) + @NotImplementedYet(strict = false,reason = "Some problem with NavigablePath creation and/or TableGroup registration under those paths") public void testOperations(SessionFactoryScope scope) { scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/attributeOverrides/TablePerClassOverrideTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/attributeOverrides/TablePerClassOverrideTests.java index 0b6271d40b..00ca7be119 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/attributeOverrides/TablePerClassOverrideTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/attributeOverrides/TablePerClassOverrideTests.java @@ -22,6 +22,7 @@ import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.FailureExpected; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; @@ -50,7 +51,7 @@ public class TablePerClassOverrideTests { @Test - @FailureExpected(reason = "@AttributeOverrides not applied for Table per class") + @NotImplementedYet(strict = false, reason = "@AttributeOverrides not applied for Table per class") public void testSchema(SessionFactoryScope scope) { MetadataImplementor metadata = scope.getMetadataImplementor(); assertTrue( SchemaUtil.isColumnPresent( "CUSTOMER", "STREET", metadata ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/LoadPlanBuilderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/LoadPlanBuilderTest.java index 28011e2083..a23a23b856 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/LoadPlanBuilderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/LoadPlanBuilderTest.java @@ -31,6 +31,7 @@ import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.FailureExpected; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.junit.jupiter.api.Test; @@ -86,7 +87,7 @@ public void testSimpleBuild(SessionFactoryScope scope) { } @Test - @FailureExpected( reason = "Cascade-driven DomainResult graph building not yet implemented" ) + @NotImplementedYet(reason = "Cascade-driven DomainResult graph building not yet implemented") public void testCascadeBasedBuild() { throw new NotYetImplementedFor6Exception( "Cascade-driven DomainResult graph building not yet implemented" ); // EntityPersister ep = (EntityPersister) sessionFactory().getClassMetadata(Message.class); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/criteria/basic/BasicCriteriaUsageTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/criteria/basic/BasicCriteriaUsageTest.java index c3aece4409..f4a3b372bf 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/criteria/basic/BasicCriteriaUsageTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/criteria/basic/BasicCriteriaUsageTest.java @@ -24,6 +24,7 @@ import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.junit.Ignore; import org.junit.Test; @@ -67,6 +68,7 @@ public void testTrivialCompilation() { @Test @TestForIssue(jiraKey = "HHH-8283") @Ignore( "Missing support for composite user types" ) + @NotImplementedYet public void testDateCompositeCustomType() { Payment payment = new Payment(); payment.setAmount( new BigDecimal( 1000 ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/CachedQueryTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/CachedQueryTest.java index 55fef84902..139cdd7235 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/CachedQueryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/CachedQueryTest.java @@ -10,43 +10,67 @@ import java.util.Map; import org.hibernate.cfg.AvailableSettings; +import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionImplementor; -import org.hibernate.jpa.HibernateEntityManagerFactory; import org.hibernate.jpa.QueryHints; -import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; import org.hibernate.stat.Statistics; -import org.hibernate.testing.FailureExpected; import org.hibernate.testing.TestForIssue; -import org.junit.Test; +import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; +import org.hibernate.testing.orm.junit.Jpa; +import org.hibernate.testing.orm.junit.NotImplementedYet; +import org.hibernate.testing.orm.junit.Setting; +import org.hibernate.testing.orm.junit.SettingProvider; +import org.junit.jupiter.api.Test; -import jakarta.persistence.EntityManager; import jakarta.persistence.SharedCacheMode; import jakarta.persistence.TypedQuery; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * @author Gail Badner */ -@TestForIssue( jiraKey = "HHH-9573" ) -public class CachedQueryTest extends BaseEntityManagerFunctionalTestCase { +@TestForIssue(jiraKey = "HHH-9573") +@Jpa( + annotatedClasses = Employee.class, + generateStatistics = true, + properties = { + @Setting(name = AvailableSettings.USE_QUERY_CACHE, value = "true"), + @Setting(name = AvailableSettings.USE_SECOND_LEVEL_CACHE, value = "true"), + }, + settingProviders = @SettingProvider(settingName = AvailableSettings.JAKARTA_SHARED_CACHE_MODE, provider = CachedQueryTest.SharedCacheModeProvider.class) +) +public class CachedQueryTest { + + protected void addConfigOptions(Map options) { + options.put( AvailableSettings.JPA_SHARED_CACHE_MODE, SharedCacheMode.ALL ); + } + + public static class SharedCacheModeProvider implements SettingProvider.Provider { + @Override + public SharedCacheMode getSetting() { + return SharedCacheMode.ALL; + } + } + @Test // todo (6.0): implement shallow query cache structure - @FailureExpected(jiraKey = "", message = "Different query cache structure") - public void testCacheableQuery() { - EntityManager em = getOrCreateEntityManager(); - em.getTransaction().begin(); - for ( int i = 0 ; i < 10 ; i++ ) { - Employee employee = new Employee( "John" + i, 20d + i); - em.persist( employee ); - } - em.getTransaction().commit(); - em.close(); + @NotImplementedYet(strict = false, reason = "Different query cache structure") + public void testCacheableQuery(EntityManagerFactoryScope scope) { + scope.inTransaction( + em -> { + for ( int i = 0; i < 10; i++ ) { + Employee employee = new Employee( "John" + i, 20d + i ); + em.persist( employee ); + } + } + ); - HibernateEntityManagerFactory hemf = entityManagerFactory(); - Statistics stats = hemf.getSessionFactory().getStatistics(); + SessionFactoryImplementor hemf = (SessionFactoryImplementor) scope.getEntityManagerFactory(); + Statistics stats = hemf.getStatistics(); assertEquals( 0, stats.getQueryCacheHitCount() ); assertEquals( 0, stats.getQueryCacheMissCount() ); @@ -57,119 +81,113 @@ public void testCacheableQuery() { stats.clear(); - em = getOrCreateEntityManager(); - em.getTransaction().begin(); - // First time the query is executed, query and results are cached. - TypedQuery query = em.createQuery( "select e from Employee e", Employee.class ) - .setHint( QueryHints.HINT_CACHEABLE, true ); - List employees = query.getResultList(); - assertEquals( 10, employees.size() ); - assertEquals( 0, stats.getQueryCacheHitCount() ); - assertEquals( 1, stats.getQueryCacheMissCount() ); - assertEquals( 1, stats.getQueryCachePutCount() ); - // the first time the query executes, stats.getSecondLevelCacheHitCount() is 0 because the - // entities are read from the query ResultSet (not from the entity cache). - assertEquals( 0, stats.getSecondLevelCacheHitCount() ); - assertEquals( 0, stats.getSecondLevelCacheMissCount() ); - assertEquals( 0, stats.getSecondLevelCachePutCount() ); + scope.inTransaction( + em -> { + TypedQuery query = em.createQuery( "select e from Employee e", Employee.class ) + .setHint( QueryHints.HINT_CACHEABLE, true ); + List employees = query.getResultList(); + assertEquals( 10, employees.size() ); + assertEquals( 0, stats.getQueryCacheHitCount() ); + assertEquals( 1, stats.getQueryCacheMissCount() ); + assertEquals( 1, stats.getQueryCachePutCount() ); + // the first time the query executes, stats.getSecondLevelCacheHitCount() is 0 because the + // entities are read from the query ResultSet (not from the entity cache). + assertEquals( 0, stats.getSecondLevelCacheHitCount() ); + assertEquals( 0, stats.getSecondLevelCacheMissCount() ); + assertEquals( 0, stats.getSecondLevelCachePutCount() ); + } + ); - em.getTransaction().commit(); - em.close(); stats.clear(); // Second time the query is executed, list of entities are read from query cache and // the entities themselves are read from the entity cache. - em = getOrCreateEntityManager(); - em.getTransaction().begin(); - query = em.createQuery( "select e from Employee e", Employee.class ) - .setHint( QueryHints.HINT_CACHEABLE, true ); - employees = query.getResultList(); - assertEquals( 10, employees.size() ); - assertEquals( 1, stats.getQueryCacheHitCount() ); - assertEquals( 0, stats.getQueryCacheMissCount() ); - assertEquals( 0, stats.getQueryCachePutCount() ); - // the first time the query executes, stats.getSecondLevelCacheHitCount() is 0 because the - // entities are read from the query ResultSet (not from the entity cache). - assertEquals( 10, stats.getSecondLevelCacheHitCount() ); - assertEquals( 0, stats.getSecondLevelCacheMissCount() ); - assertEquals( 0, stats.getSecondLevelCachePutCount() ); + scope.inTransaction( + em -> { + TypedQuery query = em.createQuery( "select e from Employee e", Employee.class ) + .setHint( QueryHints.HINT_CACHEABLE, true ); + List employees = query.getResultList(); + assertEquals( 10, employees.size() ); + assertEquals( 1, stats.getQueryCacheHitCount() ); + assertEquals( 0, stats.getQueryCacheMissCount() ); + assertEquals( 0, stats.getQueryCachePutCount() ); + // the first time the query executes, stats.getSecondLevelCacheHitCount() is 0 because the + // entities are read from the query ResultSet (not from the entity cache). + assertEquals( 10, stats.getSecondLevelCacheHitCount() ); + assertEquals( 0, stats.getSecondLevelCacheMissCount() ); + assertEquals( 0, stats.getSecondLevelCachePutCount() ); + } + ); - em.getTransaction().commit(); - em.close(); // NOTE: JPACache.evictAll() only evicts entity regions; // it does not evict the collection regions or query cache region - entityManagerFactory().getCache().evictAll(); + scope.getEntityManagerFactory().getCache().evictAll(); stats.clear(); - em = getOrCreateEntityManager(); - em.getTransaction().begin(); - query = em.createQuery( "select e from Employee e", Employee.class ) - .setHint( QueryHints.HINT_CACHEABLE, true ); - employees = query.getResultList(); - assertEquals( 10, employees.size() ); - // query is still found in the cache - assertEquals( 1, stats.getQueryCacheHitCount() ); - assertEquals( 0, stats.getQueryCacheMissCount() ); - assertEquals( 0, stats.getQueryCachePutCount() ); - // since entity regions were evicted, the 10 entities are not found, and are re-put after loading - // as each entity ID is read from the query cache, Hibernate will look the entity up in the - // cache and will not find it; that's why the "miss" and "put" counts are both 10. - assertEquals( 0, stats.getSecondLevelCacheHitCount() ); - assertEquals( 10, stats.getSecondLevelCacheMissCount() ); - assertEquals( 10, stats.getSecondLevelCachePutCount() ); + scope.inTransaction( + em -> { + TypedQuery query = em.createQuery( "select e from Employee e", Employee.class ) + .setHint( QueryHints.HINT_CACHEABLE, true ); + List employees = query.getResultList(); + assertEquals( 10, employees.size() ); + // query is still found in the cache + assertEquals( 1, stats.getQueryCacheHitCount() ); + assertEquals( 0, stats.getQueryCacheMissCount() ); + assertEquals( 0, stats.getQueryCachePutCount() ); + // since entity regions were evicted, the 10 entities are not found, and are re-put after loading + // as each entity ID is read from the query cache, Hibernate will look the entity up in the + // cache and will not find it; that's why the "miss" and "put" counts are both 10. + assertEquals( 0, stats.getSecondLevelCacheHitCount() ); + assertEquals( 10, stats.getSecondLevelCacheMissCount() ); + assertEquals( 10, stats.getSecondLevelCachePutCount() ); + } + ); - em.getTransaction().commit(); - em.close(); stats.clear(); // this time call clear the entity regions and the query cache region - em = getOrCreateEntityManager(); + scope.inEntityManager( + em -> { + em.getEntityManagerFactory().getCache().evictAll(); + em.unwrap( SessionImplementor.class ) + .getFactory() + .getCache() + .evictQueryRegions(); - em.getEntityManagerFactory().getCache().evictAll(); - em.unwrap( SessionImplementor.class ) - .getFactory() - .getCache() - .evictQueryRegions(); + em.getTransaction().begin(); + try { + TypedQuery query = em.createQuery( "select e from Employee e", Employee.class ) + .setHint( QueryHints.HINT_CACHEABLE, true ); + List employees = query.getResultList(); + assertEquals( 10, employees.size() ); + // query is no longer found in the cache + assertEquals( 0, stats.getQueryCacheHitCount() ); + assertEquals( 1, stats.getQueryCacheMissCount() ); + assertEquals( 1, stats.getQueryCachePutCount() ); + // stats.getSecondLevelCacheHitCount() is 0 because the + // entities are read from the query ResultSet (not from the entity cache). + assertEquals( 0, stats.getSecondLevelCacheHitCount() ); + assertEquals( 0, stats.getSecondLevelCacheMissCount() ); + assertEquals( 10, stats.getSecondLevelCachePutCount() ); - em.getTransaction().begin(); - query = em.createQuery( "select e from Employee e", Employee.class ) - .setHint( QueryHints.HINT_CACHEABLE, true ); - employees = query.getResultList(); - assertEquals( 10, employees.size() ); - // query is no longer found in the cache - assertEquals( 0, stats.getQueryCacheHitCount() ); - assertEquals( 1, stats.getQueryCacheMissCount() ); - assertEquals( 1, stats.getQueryCachePutCount() ); - // stats.getSecondLevelCacheHitCount() is 0 because the - // entities are read from the query ResultSet (not from the entity cache). - assertEquals( 0, stats.getSecondLevelCacheHitCount() ); - assertEquals( 0, stats.getSecondLevelCacheMissCount() ); - assertEquals( 10, stats.getSecondLevelCachePutCount() ); + em.createQuery( "delete from Employee" ).executeUpdate(); + em.getTransaction().commit(); + } + finally { + if ( em.getTransaction().isActive() ) { + em.getTransaction().rollback(); + } + } + } + ); - em.createQuery( "delete from Employee" ).executeUpdate(); - em.getTransaction().commit(); - em.close(); - } - - protected void addConfigOptions(Map options) { - options.put( AvailableSettings.JPA_SHARED_CACHE_MODE, SharedCacheMode.ALL ); - options.put( AvailableSettings.GENERATE_STATISTICS, "true" ); - options.put( AvailableSettings.USE_QUERY_CACHE, "true" ); - options.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" ); - } - - @Override - public Class[] getAnnotatedClasses() { - return new Class[]{ - Employee.class - }; } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/multiLoad/MultiLoadTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/multiLoad/MultiLoadTest.java index 74a2928426..7791aa54ea 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/multiLoad/MultiLoadTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/multiLoad/MultiLoadTest.java @@ -24,6 +24,7 @@ import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.FailureExpected; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; @@ -206,7 +207,7 @@ public void testBasicMultiLoadWithManagedAndChecking(SessionFactoryScope scope) @Test @TestForIssue(jiraKey = "HHH-12944") - @FailureExpected( reason = "Caching/CacheMode supported not yet implemented" ) + @NotImplementedYet(strict = false, reason = "Caching/CacheMode supported not yet implemented") public void testMultiLoadFrom2ndLevelCache(SessionFactoryScope scope) { final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); @@ -261,7 +262,7 @@ public void testMultiLoadFrom2ndLevelCache(SessionFactoryScope scope) { @Test @TestForIssue(jiraKey = "HHH-12944") - @FailureExpected( reason = "Caching/CacheMode supported not yet implemented" ) + @NotImplementedYet(strict = false, reason = "Caching/CacheMode supported not yet implemented") public void testUnorderedMultiLoadFrom2ndLevelCache(SessionFactoryScope scope) { final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); @@ -450,7 +451,7 @@ public void testUnorderedMultiLoadFrom2ndLevelCachePendingDeleteReturnRemoved(Se } @Test - @FailureExpected( reason = "CacheMode not yet implemented" ) + @NotImplementedYet(strict = false, reason = "CacheMode not yet implemented") public void testMultiLoadWithCacheModeIgnore(SessionFactoryScope scope) { // do the multi-load, telling Hibernate to IGNORE the L2 cache - // the end result should be that the cache is (still) empty afterwards diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/size/ManyToManySizeTest2.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/size/ManyToManySizeTest2.java index 1571a24514..6e15e13c7d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/size/ManyToManySizeTest2.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/size/ManyToManySizeTest2.java @@ -206,7 +206,6 @@ public void testSizeWithoutNestedPathAddFetchDistinct(SessionFactoryScope scope) } @Test -// @FailureExpected( reason = "org.hibernate.PropertyAccessException : Student#teacher (I think its a stack-overflow)" ) public void testSizeWithNestedPathAndImplicitJoin(SessionFactoryScope scope) { scope.inTransaction( (session) -> { @@ -288,7 +287,6 @@ public void testSizeWithNestedPathAndImplicitJoinAddFetchDistinct(SessionFactory } @Test - @FailureExpected( reason = "org.hibernate.PropertyAccessException : Student#teacher (I think its a stack-overflow)" ) public void testSizeWithNestedPath(SessionFactoryScope scope) { scope.inTransaction( (session) -> { @@ -300,12 +298,14 @@ public void testSizeWithNestedPath(SessionFactoryScope scope) { } + final SQLStatementInspector sqlStatementInspector = extractFromSession( session ); + sqlStatementInspector.clear(); List students = session.createQuery( "select student from Student student join student.teacher t where size(student.teacher.skills) > -1", Student.class ).getResultList(); assertEquals( 3L, students.size() ); - extractFromSession( session ).assertNumberOfJoins( 0, 1 ); + sqlStatementInspector.assertNumberOfJoins( 0, 1 ); students = session.createQuery( "select student from Student student join student.teacher t where size(student.teacher.skills) > 0", @@ -329,17 +329,16 @@ public void testSizeWithNestedPath(SessionFactoryScope scope) { } @Test - @FailureExpected( reason = "org.hibernate.PropertyAccessException : Student#teacher (I think its a stack-overflow)" ) public void testSizeWithNestedPathAddFetchDistinct(SessionFactoryScope scope) { scope.inTransaction( (session) -> { + final SQLStatementInspector sqlStatementInspector = extractFromSession( session ); + sqlStatementInspector.clear(); List students = session.createQuery( "select distinct student from Student student join student.teacher t join fetch student.teacher tjoin left join fetch tjoin.skills where size(student.teacher.skills) > -1", Student.class ).getResultList(); - // NOTE: An INNER JOIN is done on Teacher twice, which results in 4 joins. - // A possible optimization would be to reuse this INNER JOIN. - extractFromSession( session ).assertNumberOfJoins( 0, 4 ); + sqlStatementInspector.assertNumberOfJoins( 0, 3 ); assertEquals( 3L, students.size() ); assertTrue( Hibernate.isInitialized( students.get( 0 ).getTeacher().getSkills() ) ); assertTrue( Hibernate.isInitialized( students.get( 1 ).getTeacher().getSkills() ) ); @@ -370,16 +369,18 @@ public void testSizeWithNestedPathAddFetchDistinct(SessionFactoryScope scope) { } @Test -// @FailureExpected( reason = "org.hibernate.PropertyAccessException : Student#teacher (I think its a stack-overflow)" ) public void testSizeWithNestedPath2(SessionFactoryScope scope) { scope.inTransaction( (session) -> { + final SQLStatementInspector sqlStatementInspector = extractFromSession( session ); + sqlStatementInspector.clear(); + List students = session.createQuery( "select student from Student student join student.teacher t where size(t.skills) > -1", Student.class ).getResultList(); assertEquals( 3, students.size() ); - extractFromSession( session ).assertNumberOfJoins( 0, 1 ); + sqlStatementInspector.assertNumberOfJoins( 0, 1 ); students = session.createQuery( "select student from Student student join student.teacher t where size(t.skills) > 0", @@ -403,17 +404,19 @@ public void testSizeWithNestedPath2(SessionFactoryScope scope) { } @Test - @FailureExpected( reason = "org.hibernate.PropertyAccessException : Student#teacher (I think its a stack-overflow)" ) public void testSizeWithNestedPath2AddFetchDistinct(SessionFactoryScope scope) { scope.inTransaction( (session) -> { + final SQLStatementInspector sqlStatementInspector = extractFromSession( session ); + sqlStatementInspector.clear(); + List students = session.createQuery( "select distinct student from Student student join student.teacher t join fetch student.teacher tfetch left join fetch tfetch.skills where size(t.skills) > -1", Student.class ).getResultList(); // NOTE: An INNER JOIN is done on Teacher twice, which results in 4 joins. // A possible optimization would be to reuse this INNER JOIN. - extractFromSession( session ).assertNumberOfJoins( 0, 4 ); + sqlStatementInspector.assertNumberOfJoins( 0, 4 ); assertEquals( 3L, students.size() ); assertTrue( Hibernate.isInitialized( students.get( 0 ).getTeacher().getSkills() ) ); assertTrue( Hibernate.isInitialized( students.get( 1 ).getTeacher().getSkills() ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/sqm/exec/DiscriminatorTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/sqm/exec/DiscriminatorTests.java index 5a719991c4..d614da3e68 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/sqm/exec/DiscriminatorTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/sqm/exec/DiscriminatorTests.java @@ -17,6 +17,7 @@ import org.hibernate.testing.orm.domain.retail.Vendor; import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest; import org.hibernate.testing.orm.junit.FailureExpected; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -58,7 +59,7 @@ public void cleanUpTestData() { } @Test - @FailureExpected( reason = "selection of discriminator not yet implemented" ) + @NotImplementedYet(strict = false, reason = "selection of discriminator not yet implemented") public void testSelection() { inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/manytoone/EntityWithLazyManyToOneSelfReferenceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/manytoone/EntityWithLazyManyToOneSelfReferenceTest.java index 047321f2ab..9bb87fcd49 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/manytoone/EntityWithLazyManyToOneSelfReferenceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/manytoone/EntityWithLazyManyToOneSelfReferenceTest.java @@ -15,6 +15,7 @@ import org.hibernate.testing.orm.domain.gambit.EntityWithManyToOneSelfReference; import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.FailureExpected; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; @@ -194,7 +195,7 @@ public void testHqlSelectWithFetchJoin(SessionFactoryScope scope) { } @Test - @FailureExpected + @NotImplementedYet(strict = false) public void testGetByMultipleIds(SessionFactoryScope scope) { scope.inTransaction( diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/manytoone/EntityWithManyToOneSelfReferenceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/manytoone/EntityWithManyToOneSelfReferenceTest.java index 0fca7978a0..246d1e4a9e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/manytoone/EntityWithManyToOneSelfReferenceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/manytoone/EntityWithManyToOneSelfReferenceTest.java @@ -15,6 +15,7 @@ import org.hibernate.testing.orm.domain.gambit.EntityWithManyToOneSelfReference; import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.FailureExpected; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; @@ -193,7 +194,7 @@ public void testHqlSelectWithFetchJoin(SessionFactoryScope scope) { } @Test - @FailureExpected + @NotImplementedYet(strict = false) public void testGetByMultipleIds(SessionFactoryScope scope) { scope.inTransaction( diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/db2/DB2CustomSQLTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/db2/DB2CustomSQLTest.java index a7a8e24a7b..8395f0097e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/db2/DB2CustomSQLTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/db2/DB2CustomSQLTest.java @@ -10,6 +10,7 @@ import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport; import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.junit.Ignore; /** @@ -20,6 +21,7 @@ @RequiresDialect( DB2Dialect.class ) // todo (6.0): needs a composite user type mechanism e.g. by providing a custom embeddable strategy or istantiator @Ignore( "Missing support for composite user types" ) +@NotImplementedYet public class DB2CustomSQLTest extends CustomStoredProcTestSupport { public String[] getMappings() { return new String[] { "sql/hand/custom/db2/Mappings.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/derby/DerbyCustomSQLTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/derby/DerbyCustomSQLTest.java index afeb71bf1e..3272d7b3d1 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/derby/DerbyCustomSQLTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/derby/DerbyCustomSQLTest.java @@ -10,6 +10,7 @@ import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport; import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.junit.Ignore; /** @@ -18,6 +19,7 @@ @RequiresDialect(DerbyDialect.class) // todo (6.0): needs a composite user type mechanism e.g. by providing a custom embeddable strategy or istantiator @Ignore( "Missing support for composite user types" ) +@NotImplementedYet public class DerbyCustomSQLTest extends CustomStoredProcTestSupport { public String[] getMappings() { return new String[] {"sql/hand/custom/derby/Mappings.hbm.xml"}; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/mysql/MySQLCustomSQLTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/mysql/MySQLCustomSQLTest.java index 7ad28cb16f..4a76e9fdb3 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/mysql/MySQLCustomSQLTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/mysql/MySQLCustomSQLTest.java @@ -10,6 +10,7 @@ import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport; import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.junit.Ignore; /** @@ -20,6 +21,7 @@ @RequiresDialect( MySQLDialect.class ) // todo (6.0): needs a composite user type mechanism e.g. by providing a custom embeddable strategy or istantiator @Ignore( "Missing support for composite user types" ) +@NotImplementedYet public class MySQLCustomSQLTest extends CustomStoredProcTestSupport { public String[] getMappings() { return new String[] { "sql/hand/custom/mysql/Mappings.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/oracle/OracleCustomSQLTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/oracle/OracleCustomSQLTest.java index cd9f473b19..36ed3f8e4b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/oracle/OracleCustomSQLTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/oracle/OracleCustomSQLTest.java @@ -10,6 +10,7 @@ import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport; import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.junit.Ignore; /** @@ -20,6 +21,7 @@ @RequiresDialect( OracleDialect.class ) // todo (6.0): needs a composite user type mechanism e.g. by providing a custom embeddable strategy or istantiator @Ignore( "Missing support for composite user types" ) +@NotImplementedYet public class OracleCustomSQLTest extends CustomStoredProcTestSupport { public String[] getMappings() { return new String[] { "sql/hand/custom/oracle/Mappings.hbm.xml", "sql/hand/custom/oracle/StoredProcedures.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/sqlserver/SQLServerCustomSQLTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/sqlserver/SQLServerCustomSQLTest.java index c10beafc8c..727a73b8b2 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/sqlserver/SQLServerCustomSQLTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/sqlserver/SQLServerCustomSQLTest.java @@ -10,6 +10,7 @@ import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport; import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.junit.Ignore; /** @@ -20,6 +21,7 @@ @RequiresDialect( SQLServerDialect.class ) // todo (6.0): needs a composite user type mechanism e.g. by providing a custom embeddable strategy or istantiator @Ignore( "Missing support for composite user types" ) +@NotImplementedYet public class SQLServerCustomSQLTest extends CustomStoredProcTestSupport { public String[] getMappings() { return new String[] { "sql/hand/custom/sqlserver/Mappings.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/sybase/SybaseCustomSQLTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/sybase/SybaseCustomSQLTest.java index cc1ad287e4..4e091df45d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/sybase/SybaseCustomSQLTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/custom/sybase/SybaseCustomSQLTest.java @@ -10,6 +10,7 @@ import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport; import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.orm.junit.NotImplementedYet; import org.junit.Ignore; /** @@ -20,6 +21,7 @@ @RequiresDialect( { SybaseDialect.class }) // todo (6.0): needs a composite user type mechanism e.g. by providing a custom embeddable strategy or istantiator @Ignore( "Missing support for composite user types" ) +@NotImplementedYet public class SybaseCustomSQLTest extends CustomStoredProcTestSupport { public String[] getMappings() { return new String[] { "sql/hand/custom/sybase/Mappings.hbm.xml" };