@FailureExpected annotation added to tests in orm 6 substituted with @NotImplementedYet

This commit is contained in:
Andrea Boriero 2021-12-14 14:34:03 +01:00 committed by Andrea Boriero
parent bd9276d6d7
commit a4b574e826
17 changed files with 172 additions and 133 deletions

View File

@ -589,10 +589,7 @@ public void testSerialized() {
} }
@Test @Test
@FailureExpected( @NotImplementedYet(reason = "Support for custom composite types not implemented - org.hibernate.orm.test.annotations.entity.Ransom#getAmount")
jiraKey = "",
message = "Support for custom composite types not implemented - org.hibernate.orm.test.annotations.entity.Ransom#getAmount"
)
public void testCompositeType() throws Exception { public void testCompositeType() throws Exception {
Session s; Session s;
Transaction tx; Transaction tx;

View File

@ -30,6 +30,7 @@
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.DomainModelScope; import org.hibernate.testing.orm.junit.DomainModelScope;
import org.hibernate.testing.orm.junit.FailureExpected; 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.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
@ -91,7 +92,7 @@ public void testModel(DomainModelScope scope) {
} }
@Test @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) { public void testOperations(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -22,6 +22,7 @@
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected; 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.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
@ -50,7 +51,7 @@
public class TablePerClassOverrideTests { public class TablePerClassOverrideTests {
@Test @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) { public void testSchema(SessionFactoryScope scope) {
MetadataImplementor metadata = scope.getMetadataImplementor(); MetadataImplementor metadata = scope.getMetadataImplementor();
assertTrue( SchemaUtil.isColumnPresent( "CUSTOMER", "STREET", metadata ) ); assertTrue( SchemaUtil.isColumnPresent( "CUSTOMER", "STREET", metadata ) );

View File

@ -31,6 +31,7 @@
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected; 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.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -86,7 +87,7 @@ public void testSimpleBuild(SessionFactoryScope scope) {
} }
@Test @Test
@FailureExpected( reason = "Cascade-driven DomainResult graph building not yet implemented" ) @NotImplementedYet(reason = "Cascade-driven DomainResult graph building not yet implemented")
public void testCascadeBasedBuild() { public void testCascadeBasedBuild() {
throw new NotYetImplementedFor6Exception( "Cascade-driven DomainResult graph building not yet implemented" ); throw new NotYetImplementedFor6Exception( "Cascade-driven DomainResult graph building not yet implemented" );
// EntityPersister ep = (EntityPersister) sessionFactory().getClassMetadata(Message.class); // EntityPersister ep = (EntityPersister) sessionFactory().getClassMetadata(Message.class);

View File

@ -24,6 +24,7 @@
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.NotImplementedYet;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
@ -67,6 +68,7 @@ public void testTrivialCompilation() {
@Test @Test
@TestForIssue(jiraKey = "HHH-8283") @TestForIssue(jiraKey = "HHH-8283")
@Ignore( "Missing support for composite user types" ) @Ignore( "Missing support for composite user types" )
@NotImplementedYet
public void testDateCompositeCustomType() { public void testDateCompositeCustomType() {
Payment payment = new Payment(); Payment payment = new Payment();
payment.setAmount( new BigDecimal( 1000 ) ); payment.setAmount( new BigDecimal( 1000 ) );

View File

@ -10,43 +10,67 @@
import java.util.Map; import java.util.Map;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.jpa.HibernateEntityManagerFactory;
import org.hibernate.jpa.QueryHints; import org.hibernate.jpa.QueryHints;
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
import org.hibernate.stat.Statistics; import org.hibernate.stat.Statistics;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue; 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.SharedCacheMode;
import jakarta.persistence.TypedQuery; import jakarta.persistence.TypedQuery;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
/** /**
* @author Gail Badner * @author Gail Badner
*/ */
@TestForIssue( jiraKey = "HHH-9573" ) @TestForIssue(jiraKey = "HHH-9573")
public class CachedQueryTest extends BaseEntityManagerFunctionalTestCase { @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<SharedCacheMode> {
@Override
public SharedCacheMode getSetting() {
return SharedCacheMode.ALL;
}
}
@Test @Test
// todo (6.0): implement shallow query cache structure // todo (6.0): implement shallow query cache structure
@FailureExpected(jiraKey = "", message = "Different query cache structure") @NotImplementedYet(strict = false, reason = "Different query cache structure")
public void testCacheableQuery() { public void testCacheableQuery(EntityManagerFactoryScope scope) {
EntityManager em = getOrCreateEntityManager(); scope.inTransaction(
em.getTransaction().begin(); em -> {
for ( int i = 0 ; i < 10 ; i++ ) { for ( int i = 0; i < 10; i++ ) {
Employee employee = new Employee( "John" + i, 20d + i); Employee employee = new Employee( "John" + i, 20d + i );
em.persist( employee ); em.persist( employee );
} }
em.getTransaction().commit(); }
em.close(); );
HibernateEntityManagerFactory hemf = entityManagerFactory(); SessionFactoryImplementor hemf = (SessionFactoryImplementor) scope.getEntityManagerFactory();
Statistics stats = hemf.getSessionFactory().getStatistics(); Statistics stats = hemf.getStatistics();
assertEquals( 0, stats.getQueryCacheHitCount() ); assertEquals( 0, stats.getQueryCacheHitCount() );
assertEquals( 0, stats.getQueryCacheMissCount() ); assertEquals( 0, stats.getQueryCacheMissCount() );
@ -57,119 +81,113 @@ public void testCacheableQuery() {
stats.clear(); stats.clear();
em = getOrCreateEntityManager();
em.getTransaction().begin();
// First time the query is executed, query and results are cached. // First time the query is executed, query and results are cached.
TypedQuery<Employee> query = em.createQuery( "select e from Employee e", Employee.class ) scope.inTransaction(
.setHint( QueryHints.HINT_CACHEABLE, true ); em -> {
List<Employee> employees = query.getResultList(); TypedQuery<Employee> query = em.createQuery( "select e from Employee e", Employee.class )
assertEquals( 10, employees.size() ); .setHint( QueryHints.HINT_CACHEABLE, true );
assertEquals( 0, stats.getQueryCacheHitCount() ); List<Employee> employees = query.getResultList();
assertEquals( 1, stats.getQueryCacheMissCount() ); assertEquals( 10, employees.size() );
assertEquals( 1, stats.getQueryCachePutCount() ); assertEquals( 0, stats.getQueryCacheHitCount() );
// the first time the query executes, stats.getSecondLevelCacheHitCount() is 0 because the assertEquals( 1, stats.getQueryCacheMissCount() );
// entities are read from the query ResultSet (not from the entity cache). assertEquals( 1, stats.getQueryCachePutCount() );
assertEquals( 0, stats.getSecondLevelCacheHitCount() ); // the first time the query executes, stats.getSecondLevelCacheHitCount() is 0 because the
assertEquals( 0, stats.getSecondLevelCacheMissCount() ); // entities are read from the query ResultSet (not from the entity cache).
assertEquals( 0, stats.getSecondLevelCachePutCount() ); assertEquals( 0, stats.getSecondLevelCacheHitCount() );
assertEquals( 0, stats.getSecondLevelCacheMissCount() );
assertEquals( 0, stats.getSecondLevelCachePutCount() );
}
);
em.getTransaction().commit();
em.close();
stats.clear(); stats.clear();
// Second time the query is executed, list of entities are read from query cache and // Second time the query is executed, list of entities are read from query cache and
// the entities themselves are read from the entity cache. // the entities themselves are read from the entity cache.
em = getOrCreateEntityManager(); scope.inTransaction(
em.getTransaction().begin(); em -> {
query = em.createQuery( "select e from Employee e", Employee.class ) TypedQuery<Employee> query = em.createQuery( "select e from Employee e", Employee.class )
.setHint( QueryHints.HINT_CACHEABLE, true ); .setHint( QueryHints.HINT_CACHEABLE, true );
employees = query.getResultList(); List<Employee> employees = query.getResultList();
assertEquals( 10, employees.size() ); assertEquals( 10, employees.size() );
assertEquals( 1, stats.getQueryCacheHitCount() ); assertEquals( 1, stats.getQueryCacheHitCount() );
assertEquals( 0, stats.getQueryCacheMissCount() ); assertEquals( 0, stats.getQueryCacheMissCount() );
assertEquals( 0, stats.getQueryCachePutCount() ); assertEquals( 0, stats.getQueryCachePutCount() );
// the first time the query executes, stats.getSecondLevelCacheHitCount() is 0 because the // the first time the query executes, stats.getSecondLevelCacheHitCount() is 0 because the
// entities are read from the query ResultSet (not from the entity cache). // entities are read from the query ResultSet (not from the entity cache).
assertEquals( 10, stats.getSecondLevelCacheHitCount() ); assertEquals( 10, stats.getSecondLevelCacheHitCount() );
assertEquals( 0, stats.getSecondLevelCacheMissCount() ); assertEquals( 0, stats.getSecondLevelCacheMissCount() );
assertEquals( 0, stats.getSecondLevelCachePutCount() ); assertEquals( 0, stats.getSecondLevelCachePutCount() );
}
);
em.getTransaction().commit();
em.close();
// NOTE: JPACache.evictAll() only evicts entity regions; // NOTE: JPACache.evictAll() only evicts entity regions;
// it does not evict the collection regions or query cache region // it does not evict the collection regions or query cache region
entityManagerFactory().getCache().evictAll(); scope.getEntityManagerFactory().getCache().evictAll();
stats.clear(); stats.clear();
em = getOrCreateEntityManager(); scope.inTransaction(
em.getTransaction().begin(); em -> {
query = em.createQuery( "select e from Employee e", Employee.class ) TypedQuery<Employee> query = em.createQuery( "select e from Employee e", Employee.class )
.setHint( QueryHints.HINT_CACHEABLE, true ); .setHint( QueryHints.HINT_CACHEABLE, true );
employees = query.getResultList(); List<Employee> employees = query.getResultList();
assertEquals( 10, employees.size() ); assertEquals( 10, employees.size() );
// query is still found in the cache // query is still found in the cache
assertEquals( 1, stats.getQueryCacheHitCount() ); assertEquals( 1, stats.getQueryCacheHitCount() );
assertEquals( 0, stats.getQueryCacheMissCount() ); assertEquals( 0, stats.getQueryCacheMissCount() );
assertEquals( 0, stats.getQueryCachePutCount() ); assertEquals( 0, stats.getQueryCachePutCount() );
// since entity regions were evicted, the 10 entities are not found, and are re-put after loading // 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 // 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. // cache and will not find it; that's why the "miss" and "put" counts are both 10.
assertEquals( 0, stats.getSecondLevelCacheHitCount() ); assertEquals( 0, stats.getSecondLevelCacheHitCount() );
assertEquals( 10, stats.getSecondLevelCacheMissCount() ); assertEquals( 10, stats.getSecondLevelCacheMissCount() );
assertEquals( 10, stats.getSecondLevelCachePutCount() ); assertEquals( 10, stats.getSecondLevelCachePutCount() );
}
);
em.getTransaction().commit();
em.close();
stats.clear(); stats.clear();
// this time call clear the entity regions and the query cache region // 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.getTransaction().begin();
em.unwrap( SessionImplementor.class ) try {
.getFactory() TypedQuery<Employee> query = em.createQuery( "select e from Employee e", Employee.class )
.getCache() .setHint( QueryHints.HINT_CACHEABLE, true );
.evictQueryRegions(); List<Employee> 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(); em.createQuery( "delete from Employee" ).executeUpdate();
query = em.createQuery( "select e from Employee e", Employee.class ) em.getTransaction().commit();
.setHint( QueryHints.HINT_CACHEABLE, true ); }
employees = query.getResultList(); finally {
assertEquals( 10, employees.size() ); if ( em.getTransaction().isActive() ) {
// query is no longer found in the cache em.getTransaction().rollback();
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();
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
};
} }
} }

View File

@ -24,6 +24,7 @@
import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected; 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.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
@ -206,7 +207,7 @@ public void testBasicMultiLoadWithManagedAndChecking(SessionFactoryScope scope)
@Test @Test
@TestForIssue(jiraKey = "HHH-12944") @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) { public void testMultiLoadFrom2ndLevelCache(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
@ -261,7 +262,7 @@ public void testMultiLoadFrom2ndLevelCache(SessionFactoryScope scope) {
@Test @Test
@TestForIssue(jiraKey = "HHH-12944") @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) { public void testUnorderedMultiLoadFrom2ndLevelCache(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
@ -450,7 +451,7 @@ public void testUnorderedMultiLoadFrom2ndLevelCachePendingDeleteReturnRemoved(Se
} }
@Test @Test
@FailureExpected( reason = "CacheMode not yet implemented" ) @NotImplementedYet(strict = false, reason = "CacheMode not yet implemented")
public void testMultiLoadWithCacheModeIgnore(SessionFactoryScope scope) { public void testMultiLoadWithCacheModeIgnore(SessionFactoryScope scope) {
// do the multi-load, telling Hibernate to IGNORE the L2 cache - // do the multi-load, telling Hibernate to IGNORE the L2 cache -
// the end result should be that the cache is (still) empty afterwards // the end result should be that the cache is (still) empty afterwards

View File

@ -206,7 +206,6 @@ public void testSizeWithoutNestedPathAddFetchDistinct(SessionFactoryScope scope)
} }
@Test @Test
// @FailureExpected( reason = "org.hibernate.PropertyAccessException : Student#teacher (I think its a stack-overflow)" )
public void testSizeWithNestedPathAndImplicitJoin(SessionFactoryScope scope) { public void testSizeWithNestedPathAndImplicitJoin(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
(session) -> { (session) -> {
@ -288,7 +287,6 @@ public void testSizeWithNestedPathAndImplicitJoinAddFetchDistinct(SessionFactory
} }
@Test @Test
@FailureExpected( reason = "org.hibernate.PropertyAccessException : Student#teacher (I think its a stack-overflow)" )
public void testSizeWithNestedPath(SessionFactoryScope scope) { public void testSizeWithNestedPath(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
(session) -> { (session) -> {
@ -300,12 +298,14 @@ public void testSizeWithNestedPath(SessionFactoryScope scope) {
} }
final SQLStatementInspector sqlStatementInspector = extractFromSession( session );
sqlStatementInspector.clear();
List<Student> students = session.createQuery( List<Student> students = session.createQuery(
"select student from Student student join student.teacher t where size(student.teacher.skills) > -1", "select student from Student student join student.teacher t where size(student.teacher.skills) > -1",
Student.class Student.class
).getResultList(); ).getResultList();
assertEquals( 3L, students.size() ); assertEquals( 3L, students.size() );
extractFromSession( session ).assertNumberOfJoins( 0, 1 ); sqlStatementInspector.assertNumberOfJoins( 0, 1 );
students = session.createQuery( students = session.createQuery(
"select student from Student student join student.teacher t where size(student.teacher.skills) > 0", "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 @Test
@FailureExpected( reason = "org.hibernate.PropertyAccessException : Student#teacher (I think its a stack-overflow)" )
public void testSizeWithNestedPathAddFetchDistinct(SessionFactoryScope scope) { public void testSizeWithNestedPathAddFetchDistinct(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
(session) -> { (session) -> {
final SQLStatementInspector sqlStatementInspector = extractFromSession( session );
sqlStatementInspector.clear();
List<Student> students = session.createQuery( List<Student> 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", "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 Student.class
).getResultList(); ).getResultList();
// NOTE: An INNER JOIN is done on Teacher twice, which results in 4 joins. sqlStatementInspector.assertNumberOfJoins( 0, 3 );
// A possible optimization would be to reuse this INNER JOIN.
extractFromSession( session ).assertNumberOfJoins( 0, 4 );
assertEquals( 3L, students.size() ); assertEquals( 3L, students.size() );
assertTrue( Hibernate.isInitialized( students.get( 0 ).getTeacher().getSkills() ) ); assertTrue( Hibernate.isInitialized( students.get( 0 ).getTeacher().getSkills() ) );
assertTrue( Hibernate.isInitialized( students.get( 1 ).getTeacher().getSkills() ) ); assertTrue( Hibernate.isInitialized( students.get( 1 ).getTeacher().getSkills() ) );
@ -370,16 +369,18 @@ public void testSizeWithNestedPathAddFetchDistinct(SessionFactoryScope scope) {
} }
@Test @Test
// @FailureExpected( reason = "org.hibernate.PropertyAccessException : Student#teacher (I think its a stack-overflow)" )
public void testSizeWithNestedPath2(SessionFactoryScope scope) { public void testSizeWithNestedPath2(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
(session) -> { (session) -> {
final SQLStatementInspector sqlStatementInspector = extractFromSession( session );
sqlStatementInspector.clear();
List<Student> students = session.createQuery( List<Student> students = session.createQuery(
"select student from Student student join student.teacher t where size(t.skills) > -1", "select student from Student student join student.teacher t where size(t.skills) > -1",
Student.class Student.class
).getResultList(); ).getResultList();
assertEquals( 3, students.size() ); assertEquals( 3, students.size() );
extractFromSession( session ).assertNumberOfJoins( 0, 1 ); sqlStatementInspector.assertNumberOfJoins( 0, 1 );
students = session.createQuery( students = session.createQuery(
"select student from Student student join student.teacher t where size(t.skills) > 0", "select student from Student student join student.teacher t where size(t.skills) > 0",
@ -403,17 +404,19 @@ public void testSizeWithNestedPath2(SessionFactoryScope scope) {
} }
@Test @Test
@FailureExpected( reason = "org.hibernate.PropertyAccessException : Student#teacher (I think its a stack-overflow)" )
public void testSizeWithNestedPath2AddFetchDistinct(SessionFactoryScope scope) { public void testSizeWithNestedPath2AddFetchDistinct(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
(session) -> { (session) -> {
final SQLStatementInspector sqlStatementInspector = extractFromSession( session );
sqlStatementInspector.clear();
List<Student> students = session.createQuery( List<Student> 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", "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 Student.class
).getResultList(); ).getResultList();
// NOTE: An INNER JOIN is done on Teacher twice, which results in 4 joins. // NOTE: An INNER JOIN is done on Teacher twice, which results in 4 joins.
// A possible optimization would be to reuse this INNER JOIN. // A possible optimization would be to reuse this INNER JOIN.
extractFromSession( session ).assertNumberOfJoins( 0, 4 ); sqlStatementInspector.assertNumberOfJoins( 0, 4 );
assertEquals( 3L, students.size() ); assertEquals( 3L, students.size() );
assertTrue( Hibernate.isInitialized( students.get( 0 ).getTeacher().getSkills() ) ); assertTrue( Hibernate.isInitialized( students.get( 0 ).getTeacher().getSkills() ) );
assertTrue( Hibernate.isInitialized( students.get( 1 ).getTeacher().getSkills() ) ); assertTrue( Hibernate.isInitialized( students.get( 1 ).getTeacher().getSkills() ) );

View File

@ -17,6 +17,7 @@
import org.hibernate.testing.orm.domain.retail.Vendor; import org.hibernate.testing.orm.domain.retail.Vendor;
import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest; import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest;
import org.hibernate.testing.orm.junit.FailureExpected; 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.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -58,7 +59,7 @@ public void cleanUpTestData() {
} }
@Test @Test
@FailureExpected( reason = "selection of discriminator not yet implemented" ) @NotImplementedYet(strict = false, reason = "selection of discriminator not yet implemented")
public void testSelection() { public void testSelection() {
inTransaction( inTransaction(
session -> { session -> {

View File

@ -15,6 +15,7 @@
import org.hibernate.testing.orm.domain.gambit.EntityWithManyToOneSelfReference; import org.hibernate.testing.orm.domain.gambit.EntityWithManyToOneSelfReference;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected; 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.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
@ -194,7 +195,7 @@ public void testHqlSelectWithFetchJoin(SessionFactoryScope scope) {
} }
@Test @Test
@FailureExpected @NotImplementedYet(strict = false)
public void testGetByMultipleIds(SessionFactoryScope scope) { public void testGetByMultipleIds(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(

View File

@ -15,6 +15,7 @@
import org.hibernate.testing.orm.domain.gambit.EntityWithManyToOneSelfReference; import org.hibernate.testing.orm.domain.gambit.EntityWithManyToOneSelfReference;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected; 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.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
@ -193,7 +194,7 @@ public void testHqlSelectWithFetchJoin(SessionFactoryScope scope) {
} }
@Test @Test
@FailureExpected @NotImplementedYet(strict = false)
public void testGetByMultipleIds(SessionFactoryScope scope) { public void testGetByMultipleIds(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(

View File

@ -10,6 +10,7 @@
import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport; import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport;
import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.orm.junit.NotImplementedYet;
import org.junit.Ignore; import org.junit.Ignore;
/** /**
@ -20,6 +21,7 @@
@RequiresDialect( DB2Dialect.class ) @RequiresDialect( DB2Dialect.class )
// todo (6.0): needs a composite user type mechanism e.g. by providing a custom embeddable strategy or istantiator // 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" ) @Ignore( "Missing support for composite user types" )
@NotImplementedYet
public class DB2CustomSQLTest extends CustomStoredProcTestSupport { public class DB2CustomSQLTest extends CustomStoredProcTestSupport {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "sql/hand/custom/db2/Mappings.hbm.xml" }; return new String[] { "sql/hand/custom/db2/Mappings.hbm.xml" };

View File

@ -10,6 +10,7 @@
import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport; import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport;
import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.orm.junit.NotImplementedYet;
import org.junit.Ignore; import org.junit.Ignore;
/** /**
@ -18,6 +19,7 @@
@RequiresDialect(DerbyDialect.class) @RequiresDialect(DerbyDialect.class)
// todo (6.0): needs a composite user type mechanism e.g. by providing a custom embeddable strategy or istantiator // 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" ) @Ignore( "Missing support for composite user types" )
@NotImplementedYet
public class DerbyCustomSQLTest extends CustomStoredProcTestSupport { public class DerbyCustomSQLTest extends CustomStoredProcTestSupport {
public String[] getMappings() { public String[] getMappings() {
return new String[] {"sql/hand/custom/derby/Mappings.hbm.xml"}; return new String[] {"sql/hand/custom/derby/Mappings.hbm.xml"};

View File

@ -10,6 +10,7 @@
import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport; import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport;
import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.orm.junit.NotImplementedYet;
import org.junit.Ignore; import org.junit.Ignore;
/** /**
@ -20,6 +21,7 @@
@RequiresDialect( MySQLDialect.class ) @RequiresDialect( MySQLDialect.class )
// todo (6.0): needs a composite user type mechanism e.g. by providing a custom embeddable strategy or istantiator // 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" ) @Ignore( "Missing support for composite user types" )
@NotImplementedYet
public class MySQLCustomSQLTest extends CustomStoredProcTestSupport { public class MySQLCustomSQLTest extends CustomStoredProcTestSupport {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "sql/hand/custom/mysql/Mappings.hbm.xml" }; return new String[] { "sql/hand/custom/mysql/Mappings.hbm.xml" };

View File

@ -10,6 +10,7 @@
import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport; import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport;
import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.orm.junit.NotImplementedYet;
import org.junit.Ignore; import org.junit.Ignore;
/** /**
@ -20,6 +21,7 @@
@RequiresDialect( OracleDialect.class ) @RequiresDialect( OracleDialect.class )
// todo (6.0): needs a composite user type mechanism e.g. by providing a custom embeddable strategy or istantiator // 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" ) @Ignore( "Missing support for composite user types" )
@NotImplementedYet
public class OracleCustomSQLTest extends CustomStoredProcTestSupport { public class OracleCustomSQLTest extends CustomStoredProcTestSupport {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "sql/hand/custom/oracle/Mappings.hbm.xml", "sql/hand/custom/oracle/StoredProcedures.hbm.xml" }; return new String[] { "sql/hand/custom/oracle/Mappings.hbm.xml", "sql/hand/custom/oracle/StoredProcedures.hbm.xml" };

View File

@ -10,6 +10,7 @@
import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport; import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport;
import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.orm.junit.NotImplementedYet;
import org.junit.Ignore; import org.junit.Ignore;
/** /**
@ -20,6 +21,7 @@
@RequiresDialect( SQLServerDialect.class ) @RequiresDialect( SQLServerDialect.class )
// todo (6.0): needs a composite user type mechanism e.g. by providing a custom embeddable strategy or istantiator // 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" ) @Ignore( "Missing support for composite user types" )
@NotImplementedYet
public class SQLServerCustomSQLTest extends CustomStoredProcTestSupport { public class SQLServerCustomSQLTest extends CustomStoredProcTestSupport {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "sql/hand/custom/sqlserver/Mappings.hbm.xml" }; return new String[] { "sql/hand/custom/sqlserver/Mappings.hbm.xml" };

View File

@ -10,6 +10,7 @@
import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport; import org.hibernate.orm.test.sql.hand.custom.CustomStoredProcTestSupport;
import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.orm.junit.NotImplementedYet;
import org.junit.Ignore; import org.junit.Ignore;
/** /**
@ -20,6 +21,7 @@
@RequiresDialect( { SybaseDialect.class }) @RequiresDialect( { SybaseDialect.class })
// todo (6.0): needs a composite user type mechanism e.g. by providing a custom embeddable strategy or istantiator // 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" ) @Ignore( "Missing support for composite user types" )
@NotImplementedYet
public class SybaseCustomSQLTest extends CustomStoredProcTestSupport { public class SybaseCustomSQLTest extends CustomStoredProcTestSupport {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "sql/hand/custom/sybase/Mappings.hbm.xml" }; return new String[] { "sql/hand/custom/sybase/Mappings.hbm.xml" };