From: Jakub M. (JIRA) <no...@at...> - 2006-06-07 17:16:22
|
Invalid SQL generated for mapping with property-ref --------------------------------------------------- Key: HHH-1819 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1819 Project: Hibernate3 Type: Bug Components: query-hql Versions: 3.1.3 Environment: Oracle 8.1.7 Reporter: Jakub Mendys Priority: Critical Consider mappings: <class name="MedDRATerm" table="MBROW_MEDDRA_TERMS" mutable="false" batch-size="50"> <cache usage="read-only" region="dictionary" /> <id name="medDRATermId" type="long" column="TERM_ID"> <generator class="assigned" /> </id> <map name="termNames" table="MBROW_TERM_NAMES" lazy="true" batch-size="50"> <cache usage="read-only" region="dictionary" /> <key column="MEDDRA_CODE" property-ref="medDRACode" /> <index column="LANGUAGE_ID" type="com.roche.dss.meddra.dao.type.LanguageType" /> <element column="NAME" type="string" /> </map> <property name="medDRACode" column="MEDDRA_CODE" type="com.roche.dss.meddra.dao.type.MedDRACodeType" /> </class> <class name="MedDRATermInstance" table="MBROW_MEDDRA_TREES" mutable="false"> <cache usage="read-only" region="dictionary" /> <id name="medDRATermInstanceId" type="long" column="NODE_ID"> <generator class="assigned" /> </id> <many-to-one name="medDRATerm" class="MedDRATerm" column="TERM_ID" fetch="join" not-null="true" insert="false" update="false" /> </class> and a HQL query: from MedDRATermInstance i where i.medDRATermInstanceId is not null and i.medDRATerm.termNames[1] like 'headache' Having this Hibernate will generate following SQL: SELECT ... FROM orcl_gthes.mbrow_meddra_trees meddraterm0_, orcl_gthes.mbrow_term_names termnames2_ WHERE meddraterm1_.meddra_code = termnames2_.meddra_code AND termnames2_.language_id = 1 AND meddraterm0_.term_id = meddraterm1_.term_id AND (termnames2_.NAME LIKE 'headache') Please note that WHERE clause refers to alias meddraterm1_ which is not mentioned in FROM section!!!! -- 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.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Per-Olov W. (JIRA) <no...@at...> - 2006-06-12 14:18:33
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1819?page=comments#action_23323 ] Per-Olov Wingren commented on HHH-1819: --------------------------------------- I have also this problem. I have a Node class which has a 1 to 1 relationship to an Address. The Address has a Map, addressLines, where the both keys and values are Strings. I run a query on Nodes like: "where this.addressLines['GlobalLocationId']='link'" In the select statement created by Hibernate, the where clause refers to an alias that is never defined. This problem occures when using the new ASTQueryTranslatorFactory. My current workaround is to use org.hibernate.hql.classic.ClassicQueryTranslatorFactory, which works perfectly well. I use Oracle 10.2, Hibernate 3.1.3. > Invalid SQL generated for mapping with property-ref > --------------------------------------------------- > > Key: HHH-1819 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1819 > Project: Hibernate3 > Type: Bug > Components: query-hql > Versions: 3.1.3 > Environment: Oracle 8.1.7 > Reporter: Jakub Mendys > Priority: Critical > > > Consider mappings: > <class name="MedDRATerm" table="MBROW_MEDDRA_TERMS" mutable="false" > batch-size="50"> > <cache usage="read-only" region="dictionary" /> > <id name="medDRATermId" type="long" column="TERM_ID"> > <generator class="assigned" /> > </id> > <map name="termNames" table="MBROW_TERM_NAMES" lazy="true" > batch-size="50"> > <cache usage="read-only" region="dictionary" /> > <key column="MEDDRA_CODE" property-ref="medDRACode" /> > <index column="LANGUAGE_ID" > type="com.roche.dss.meddra.dao.type.LanguageType" /> > <element column="NAME" type="string" /> > </map> > <property name="medDRACode" column="MEDDRA_CODE" > type="com.roche.dss.meddra.dao.type.MedDRACodeType" /> > </class> > <class name="MedDRATermInstance" table="MBROW_MEDDRA_TREES" > mutable="false"> > <cache usage="read-only" region="dictionary" /> > <id name="medDRATermInstanceId" type="long" column="NODE_ID"> > <generator class="assigned" /> > </id> > <many-to-one name="medDRATerm" class="MedDRATerm" > column="TERM_ID" fetch="join" not-null="true" insert="false" > update="false" /> > </class> > and a HQL query: > from MedDRATermInstance i where i.medDRATermInstanceId is not null and i.medDRATerm.termNames[1] like 'headache' > Having this Hibernate will generate following SQL: > SELECT ... > FROM orcl_gthes.mbrow_meddra_trees meddraterm0_, > orcl_gthes.mbrow_term_names termnames2_ > WHERE meddraterm1_.meddra_code = termnames2_.meddra_code > AND termnames2_.language_id = 1 > AND meddraterm0_.term_id = meddraterm1_.term_id > AND (termnames2_.NAME LIKE 'headache') > Please note that WHERE clause refers to alias meddraterm1_ which is not mentioned in FROM section!!!! -- 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.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |