Hello,
My name is Sabeeh. I am currently working on an application which uses hibernate at back end for retrieving records from the DB.
The problem is that when I try to fetch records using query catching the many-to-one records are not cached in the record set.
e.g.
I am using the following HQL
Query query = session.createQuery("from com.salesgene.common.bean.hibernate.Task as task left join fetch task.employeeByAssignee");
query.setCacheRegion("Task");
query.setCacheable(true);
query.list();
My Task.xml file is as follows
-----------------------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class
name="com.salesgene.common.bean.hibernate.Task"
table="TASK"
>
<cache
usage="read-write"
region="Task"
/>
<many-to-one
name="employeeByAssignee"
class="com.salesgene.common.bean.hibernate.Employee"
not-null="false"
fetch="join"
>
<column name="ASSIGNEE" />
</many-to-one>
</class>
</hibernate-mapping>
-----------------------------------------------------------------------
In query.list(); it gives me all the records related to Task but does not gives the employeeByAssignee records. Can anyone please tell me how to cache <many-to-one> records using query caching.
Any help in this regard will be highly appreciated.
Many thanks and regards,
Sabeeh
|