Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0
Mapping documents:
History.hbm.xml
Code:
<id name="id" type="java.lang.Long">
<column name="ID" />
<generator class="sequence" >
<param name="sequence">HISTORY_ID_SEQ</param>
</generator>
</id>
<many-to-one name="evn" class="Evn" cascade="none">
<column name="fk_evn_id" not-null="true" />
</many-to-one>
evn.hbm.xmlCode:
<list
name="histories"
inverse="true"
cascade="all-delete-orphan"
fetch="select"
lazy="true">
<key>
<column
name="fk_evn_Id"
not-null="true" />
</key>
<index column="ID" type="java.lang.Long"></index>
<one-to-many class="History" />
</list>
Code between sessionFactory.openSession() and session.close():Full stack trace of any exception that occurs:Name and version of the database you are using: DB2 8.0
The generated SQL (show_sql=true):
Code:
select
this_.ID
from
EVN.EVN this_
where
and exists (
select
*
from
EVN.HISTORY this0__
where
this0__.INTERNALSTATE in (
50, 52, 55
)
[red] and this_.ID=this0__.fk_evn_id [/red]
)
Debug level Hibernate log excerpt:Problems with Session and transaction handling?
As you see, there is a many-to-one mapping in evn and history tables. The sql part in red is not generated. This is hampering the performance of the job a lot. Please suggest how to include the sql in red part through Criteria API. Please note we are not using hql or any other way ONLY Critera API of hibernate.
Read this:
http://hibernate.org/42.htmlCode: