Hi, I am using Hibernate 3.2.5 and need some help to resolve this issue.
I have following mapping (showing part of it for sake of brevity)
Code:
<class name="xyz.Case" table="CASE" dynamic-update="true" dynamic-insert="true">
<id name="id" type="CaseIDUserType" column="ID">
<generator class="assigned" />
</id>
.
.
.
.
<bag name="documents" cascade="all" lazy="true" table="DOCUMENT">
<key column="CASE_ID" />
<composite-element class="xyz.Document">
<property name="caseDocument" type="DocumentUserType">
<column name="DOC_ID" not-null="true"/>
<column name="DOC_VERSION_ID" not-null="false"/>
</property>
</composite-element>
</bag>
I am using following hql to fetch cases based on document's id and ignoring doc_version_id
Code:
select case
from Case case
join case.documents as document
where document.caseDocument.id = :documentId
but this is resulting in sql like
select * from case c inner join Document d on c.id = d.case_id where d.id = ?
while I was expecting
select * from case c inner join Document d on c.id = d.case_id where d.doc_id = ?
Could anybody guide me what I am doing wrong? Is this even possible using hql?
Any help is highly appreciated.