[Hibernate-JIRA] Commented: (HHH-1930) QuerySyntaxException "with-clause expressions did not reference from-clause element to which the with-clause was associated"
by Mike Ressler (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1930?page=c... ]
Mike Ressler commented on HHH-1930:
-----------------------------------
Spoke too soon. The generated SQL doesn't include the with clause at all, all my data was messed up:
HQL:
select person, count(data.referenceMe) from model.DataAboutPerson as data right join data.whoImAllAbout as person with (data.referenceMe like 'me%')
SQL:
select person1_.person as col_0_0_, count(dataaboutp0_.referenceme) as col_1_0_, person1_.person as person1_, person1_.name as name1_ from dataaboutperson dataaboutp0_ right outer join people person1_ on dataaboutp0_.person=person1_.person
The ON keyword exists, but the "like 'me%'" information is lost. Looks like I'll need to dig deeper into the SQL generation code to find where the info is lost. The log4j debug logs don't seem to be leading me in any particular direction.
Anyone watching this bug that can point me in the right direction in the SQL generation code? Or anyone that might know the underlying reason why this isn't supported already?
> QuerySyntaxException "with-clause expressions did not reference from-clause element to which the with-clause was associated"
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: HHH-1930
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1930
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.1.3, 3.2.0 cr1, 3.2.0.cr2, 3.2.0.cr3
> Reporter: Manfred Geiler
> Attachments: HibernateTestCase.zip
>
>
> In Version 3.1.2 the following "EventManager" HQL query worked fine:
> select p from Person p join p.emailAddresses as email with email = 'xyz'
> and produced an SQL query like this:
> select person0_.PERSON_ID as PERSON1_2_, person0_.age as age2_, person0_.firstname as firstname2_, person0_.lastname as lastname2_
> from PERSON person0_
> inner join PERSON_EMAIL_ADDR emailaddre1_
> on person0_.PERSON_ID=emailaddre1_.PERSON_ID and (emailaddre1_.EMAIL_ADDR='xyz')
> From Version 3.1.3 on this HQL throws the following QuerySyntaxException:
> "with-clause expressions did not reference from-clause element to which the with-clause was associated"
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years
[Hibernate-JIRA] Commented: (HHH-1930) QuerySyntaxException "with-clause expressions did not reference from-clause element to which the with-clause was associated"
by Antonio Juarez (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1930?page=c... ]
Antonio Juarez commented on HHH-1930:
-------------------------------------
I don't think we can just comment the lines out - there should be some kind of restriction on this WITH part of the query. It doesn't need to reference the right-hand side, but I believe it should reference either the right-hand or the left-hand side of the query, and that does call for some validation. Maybe the if() condition could be replaced by something like:
if ( referencedFromElement != fromElement && referencedFromElement!=leftHandSideFromElement) {
throw new InvalidWithClausException(......);
}
IMO
> QuerySyntaxException "with-clause expressions did not reference from-clause element to which the with-clause was associated"
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: HHH-1930
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1930
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.1.3, 3.2.0 cr1, 3.2.0.cr2, 3.2.0.cr3
> Reporter: Manfred Geiler
> Attachments: HibernateTestCase.zip
>
>
> In Version 3.1.2 the following "EventManager" HQL query worked fine:
> select p from Person p join p.emailAddresses as email with email = 'xyz'
> and produced an SQL query like this:
> select person0_.PERSON_ID as PERSON1_2_, person0_.age as age2_, person0_.firstname as firstname2_, person0_.lastname as lastname2_
> from PERSON person0_
> inner join PERSON_EMAIL_ADDR emailaddre1_
> on person0_.PERSON_ID=emailaddre1_.PERSON_ID and (emailaddre1_.EMAIL_ADDR='xyz')
> From Version 3.1.3 on this HQL throws the following QuerySyntaxException:
> "with-clause expressions did not reference from-clause element to which the with-clause was associated"
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years
[Hibernate-JIRA] Commented: (HHH-1930) QuerySyntaxException "with-clause expressions did not reference from-clause element to which the with-clause was associated"
by Mike Ressler (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1930?page=c... ]
Mike Ressler commented on HHH-1930:
-----------------------------------
Commented out HqlSqlWalker.handleWithFragment lines 362-364 in the trunk version this evening and the TestCase passes. Since the version in trunk will change, the three lines I commented out were:
if ( referencedFromElement != fromElement ) {
throw new InvalidWithClauseException( "with-clause expressions did not reference from-clause element to which the with-clause was associated" );
}
If this is an acceptable fix for this bug, I'll create a patch file to apply to trunk. Let me know if you'd like me to do anything else to verify this fix.
Other Notes:
It seems like the with clause should be able to refer to either part of the referenced "from" element. I should be able to limit the sql results based on attributes of either part of a join statement, not just the right hand side of the join. So this begs the question, why is this check necessary?
I'm sure I'm missing something here, any comments would be appreciated.
> QuerySyntaxException "with-clause expressions did not reference from-clause element to which the with-clause was associated"
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: HHH-1930
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1930
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.1.3, 3.2.0 cr1, 3.2.0.cr2, 3.2.0.cr3
> Reporter: Manfred Geiler
> Attachments: HibernateTestCase.zip
>
>
> In Version 3.1.2 the following "EventManager" HQL query worked fine:
> select p from Person p join p.emailAddresses as email with email = 'xyz'
> and produced an SQL query like this:
> select person0_.PERSON_ID as PERSON1_2_, person0_.age as age2_, person0_.firstname as firstname2_, person0_.lastname as lastname2_
> from PERSON person0_
> inner join PERSON_EMAIL_ADDR emailaddre1_
> on person0_.PERSON_ID=emailaddre1_.PERSON_ID and (emailaddre1_.EMAIL_ADDR='xyz')
> From Version 3.1.3 on this HQL throws the following QuerySyntaxException:
> "with-clause expressions did not reference from-clause element to which the with-clause was associated"
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years
[Hibernate-JIRA] Created: (HHH-3630) When querying for component, Map collections inside components not loaded
by Gino Miceli (JIRA)
When querying for component, Map collections inside components not loaded
--------------------------------------------------------------------------
Key: HHH-3630
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3630
Project: Hibernate Core
Issue Type: Bug
Environment: 3.2.6-GA, Oracle and HSQLDB, JDK 1.5
Reporter: Gino Miceli
Attachments: hibernate-test.zip
Given the following mapping:
<code>
<class name="Car" table="CAR">
<id name="id" column="ID" type="long">
<generator class="native"/>
</id>
<property name="make" column="MAKE"/>
<property name="model" column="MODEL"/>
<component name="engine" class="Engine">
<property name="make" column="ENGINE_MAKE"/>
<property name="model" column="ENGINE_MODEL"/>
<map name="mountParts" table="ENGINE_MOUNT">
<key column="CAR_ID"/>
<map-key column="PART_NAME" type="string" />
<element column="PART" type="string" />
</map>
</component>
</class>
</code>
We are able to get the entire Car object in HQL like so:
<code>
select car from Car car where car.id=1
</code>
This generates the following SQL:
<code>
select
mountparts0_.CAR_ID as CAR1_0_,
mountparts0_.PART as PART0_,
mountparts0_.PART_NAME as PART3_0_
from
ENGINE_MOUNT mountparts0_
where
mountparts0_.CAR_ID=?
</code>
In this case, the map contained in the 'engine' component is loaded correctly. If we query the component property directly, however:
<code>
select car.engine from Car car where car.id=1
</code>
Instances of Engine are returned, however the contained map is null. Looking at the SQL, it appears not attempt is made to load the inner map property:
<code>
select
car0_.ENGINE_MAKE as col_0_0_,
car0_.ENGINE_MODEL as col_0_1_
from
CAR car0_
where
car0_.ID=1
</code>
Anyone?!
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years