HHH-9448 : Association is not fetched when EntityGraph has explicit fetch and query has implicit join

(cherry picked from commit 180e714b7c)
This commit is contained in:
Gail Badner 2015-03-19 21:58:30 -07:00
parent 181faee517
commit 0403ee78af
2 changed files with 10 additions and 4 deletions

View File

@ -95,8 +95,9 @@ public class EntityGraphQueryHint {
final Type propertyType = origin.getPropertyType( attributeName, attributeName );
try {
FromElement fromElement = null;
if ( !explicitFetches.containsKey( role ) ) {
FromElement fromElement = explicitFetches.get( role );
boolean explicitFromElement = false;
if ( fromElement == null ) {
if ( propertyType.isEntityType() ) {
final EntityType entityType = (EntityType) propertyType;
@ -137,10 +138,16 @@ public class EntityGraphQueryHint {
queryableCollection, collectionType.getRole(), JoinType.LEFT_OUTER_JOIN, true, false
);
}
} else {
explicitFromElement = true;
fromElement.setInProjectionList( true );
fromElement.setFetch( true );
}
if ( fromElement != null ) {
fromElements.add( fromElement );
if( !explicitFromElement ){
fromElements.add( fromElement );
}
// recurse into subgraphs
for ( Subgraph<?> subgraph : attributeNode.getSubgraphs().values() ) {

View File

@ -191,7 +191,6 @@ public class QueryHintEntityGraphTest extends BaseEntityManagerFunctionalTestCas
@Test
@TestForIssue( jiraKey = "HHH-9448")
@FailureExpected( jiraKey = "HHH-9448")
public void testLoadGraphWithRestriction() {
EntityManager entityManager = getOrCreateEntityManager();
entityManager.getTransaction().begin();