Hibernate version:
3.2
Mapping documents:
class A:
<class name="VTR" table="VTR">
<id name="RId" column="RID">
<generator class="assigned"/>
</id>
<property name="vid" column="VID"/>
<property name="pt" column="PT"/>
</class>
Class B:
<class name="R" table="R" lazy="true"
batch-size="6">
<cache usage="read-write"/>
<id name="id" column="RLID">
<generator class="increment"/>
</id>
<property name="name" column="NAME" not-null="true"/>
<property name="des" column="DES"/>
Code between sessionFactory.openSession() and session.close():
Query query=sess.createSQLQuery("SELECT vtr.* from R r, VTR vtr where VID = "+ verId +" and RID= RLID").addEntity("vtr",VTR.class);
List list=query.list();
return list;
Full stack trace of any exception that occurs:
There is no error.When I try to retrieve the values it works fine as long as combination of column values RId and vid is unique.But Where these two columns are same but the third one is distinct , it just shows the first row where the above condition holds true and it shows up that many times as the number of records retrieved.
So it shows only the first row where the condition holds true.
The most wierd thing is that the sql generated works fine and gives me the desired results.
I have tried using both SQLQuery and Query , but both give the undesired results.
The generated SQL (show_sql=true):
SELECT vtr.* from R r, VTR vtr where VID = 1065 and RID=RLID
Any Comments..........?
|