HHH-14124 Test that the FETCH entitygraph semantic overrides EAGER associations to LAZY
This commit is contained in:
parent
6f6874b8cf
commit
1d965227c4
|
@ -186,7 +186,10 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase {
|
|||
assertFalse( Hibernate.isInitialized( cEntity.getC() ) );
|
||||
assertFalse( Hibernate.isInitialized( cEntity.getdList() ) );
|
||||
|
||||
assertEquals( 1L, statistics.getPrepareStatementCount() );
|
||||
assertTrue( Hibernate.isInitialized( cEntity.getEagerC() ) );
|
||||
|
||||
// 1 + 1 for the eager C
|
||||
assertEquals( 2L, statistics.getPrepareStatementCount() );
|
||||
} );
|
||||
}
|
||||
|
||||
|
@ -217,7 +220,12 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase {
|
|||
assertTrue( Hibernate.isInitialized( dEntity.getE() ) );
|
||||
} );
|
||||
|
||||
assertEquals( 1L, statistics.getPrepareStatementCount() );
|
||||
// With LOAD semantic, attributes that are not mentioned in the graph are LAZY or EAGER,
|
||||
// depending on the mapping.
|
||||
assertTrue( Hibernate.isInitialized( cEntity.getEagerC() ) );
|
||||
|
||||
// 1 + 1 for the eager C
|
||||
assertEquals( 2L, statistics.getPrepareStatementCount() );
|
||||
} );
|
||||
}
|
||||
|
||||
|
@ -247,6 +255,10 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase {
|
|||
assertTrue( Hibernate.isInitialized( dEntity.getE() ) );
|
||||
} );
|
||||
|
||||
// With FETCH semantic, attributes that are not mentioned in the graph are LAZY,
|
||||
// even if they were EAGER in the mapping.
|
||||
assertFalse( Hibernate.isInitialized( cEntity.getEagerC() ) );
|
||||
|
||||
assertEquals( 1L, statistics.getPrepareStatementCount() );
|
||||
} );
|
||||
}
|
||||
|
@ -366,6 +378,9 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private CEntity c;
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
private CEntity eagerC;
|
||||
|
||||
@OneToMany(
|
||||
fetch = FetchType.LAZY,
|
||||
mappedBy = "c",
|
||||
|
@ -419,6 +434,14 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase {
|
|||
this.c = c;
|
||||
}
|
||||
|
||||
public CEntity getEagerC() {
|
||||
return eagerC;
|
||||
}
|
||||
|
||||
public void setEagerC(CEntity eagerC) {
|
||||
this.eagerC = eagerC;
|
||||
}
|
||||
|
||||
public List<DEntity> getdList() {
|
||||
return dList;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue