Bug 1109449 - (GSS)(6.4.0) HHH-9090: HQL: parser is trying to reuse parent implied join for subquery
Summary: (GSS)(6.4.0) HHH-9090: HQL: parser is trying to reuse parent implied join for...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate
Version: 6.2.3
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: DR11
: EAP 6.4.0
Assignee: Gail Badner
QA Contact: Martin Simka
URL:
Whiteboard:
Depends On:
Blocks: 1118373 1121629
TreeView+ depends on / blocked
 
Reported: 2014-06-14 03:55 UTC by Stephen Fikes
Modified: 2019-08-19 12:45 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1118373 (view as bug list)
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Stephen Fikes 2014-06-14 03:55:35 UTC
Description of problem:

org.hibernate.QueryException: could not resolve property: name of: TestClass2 [from TestClass1 as testClass1 where testClass1.testClass2.title='test2' and exists (from testClass1.testClass2.testClass3Set as testClass3 where testClass3.name = 'test3first')]

See https://hibernate.atlassian.net/browse/HHH-9090 for further description

Version-Release number of selected component (if applicable):

Hibernate core 4.x

How reproducible:

Consistently

Steps to Reproduce:

See https://hibernate.atlassian.net/browse/HHH-9090 for full testcase

1. Create three entities with the following basic structure:

@Entity
public class TestClass1 implements Serializable {
    ...
    @OneToOne(fetch = FetchType.EAGER)
    private TestClass2 testClass2;
    ...
}

@Entity
public class TestClass2 implements Serializable {
    ...
    @OneToMany
    private Set<TestClass3> testClass3Set = new HashSet<TestClass3>();
    ...
}

@Entity
public class TestClass3 implements Serializable {
    ...
    private String name;
    ...
}

2. Execute the following query:

String query = "from TestClass1 as testClass1 " +
	"where " +
	"testClass1.testClass2.title='test2' and " +
	"exists (from testClass1.testClass2.testClass3Set as testClass3 where testClass3.name = 'test3first')";
List a = hibernateSession.createQuery(query).list();


Actual results:

org.hibernate.QueryException: could not resolve property: name of: TestClass2 [from TestClass1 as testClass1 where testClass1.testClass2.title='test2' and exists (from testClass1.testClass2.testClass3Set as testClass3 where testClass3.name = 'test3first')]
	at org.hibernate.QueryException.generateQueryException(QueryException.java:137)
	at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:120)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:234)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)
	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:126)
	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:88)
	at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190)
	...

Expected results:

The query should run with no exception.

Additional info:

The following query (omitting only the first condition - which also works by itself) completes with no exception:

from TestClass1 as testClass1 where exists (from testClass1.testClass2.testClass3Set as testClass3 where testClass3.name = 'test3first')

Stepping through the code in the debugger, I think seems in the failing case we try to find the 'name' property in Set<TestClass3>. The root exception is raised first in the below stack:

Thread [main] (Class load: QueryException)	
BasicEntityPropertyMapping(AbstractPropertyMapping).propertyException(String) line: 83	
	BasicEntityPropertyMapping(AbstractPropertyMapping).toType(String) line: 77	
	SingleTableEntityPersister(AbstractEntityPersister).getSubclassPropertyTableNumber(String) line: 1995	
	...	

This occurs because the below returns null:

     typesByPropertyPath.get(propertyName); // AbstractPropertyMapping.java line 75

Comment 3 Gail Badner 2014-08-13 18:08:32 UTC
This has been fixed in upstream 4.2 branch.

Comment 4 Gail Badner 2014-11-21 02:54:29 UTC
Fixed for EAP 6.4.0.

Comment 5 Kabir Khan 2014-11-21 11:34:54 UTC
Fixed by Hibernate 4.2.16.Final upgrade https://bugzilla.redhat.com/show_bug.cgi?id=1121629

Comment 6 Martin Simka 2014-11-27 12:13:21 UTC
verified on EAP 6.4.0.DR11 / Hibernate 4.2.16


Note You need to log in before you can comment on or make changes to this bug.