-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Simple Select doesnt return desired results
PostPosted: Wed Jul 25, 2007 11:09 am 
Beginner
Beginner

Joined: Fri May 11, 2007 11:03 am
Posts: 32
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..........?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 25, 2007 6:56 pm 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
I'm confused by the following:

"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"

Since RId is the primary key of your VTR table its value cannot be duplicated so the situation "Where these two columns are same" could never arise.

Mike


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.