-->
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.  [ 1 post ] 
Author Message
 Post subject: SubQuery/HQL help
PostPosted: Thu Aug 12, 2004 11:59 am 
Newbie

Joined: Tue Jun 22, 2004 12:41 pm
Posts: 1
Hibernate version 2.1.6

<hibernate-mapping>
<class name="com.pweagleinc.applications.businessobjects.F41021" table="F41021">
<id name="item_Short"
type="java.lang.Integer"
column="LIITM">
<generator class="native"/>
</id>
<property name="item_BusinessUnit" column="LIMCU"/>
<property name="item_Location" column="LILOCN"/>
<property name="item_OnHand" column="LIPQOH"/>
<property name="item_PurchaseOrder" column="LIPREQ"/>
<property name="item_WorkOrder" column="LIQWBO"/>
<property name="item_HardCommit" column="LIHCOM"/>
<property name="item_SoftCommit" column="LIPCOM"/>
</class>
</hibernate-mapping>

<hibernate-mapping>
<class name="com.pweagleinc.applications.businessobjects.F4101LB" table="F4101LB">
<id name="item_Short"
column="IMITM"
type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="item_Long" column="IMLITM"/>
</class>
</hibernate-mapping>


String sql="from F41021 as f41021 " +
"where f41021.item_Location = ' ' " +
"AND f41021.item_OnHand != 0 " +
"AND f41021.item_Short " +
"in (select f4101LB.item_Short " +
"from F4101LB as f4101LB " +
"where f4101LB.item_Long = '3408001504')";

Query q = hiberSession.createQuery(sql);
List avails = q.list();
tx.commit();
AS400DBUtil.closeSession();
return avails;

DB2/400:V5r2

I am a newb.

Using the above code I am trying to return Summary Availability for a specific item. Using the code with or without the subquery and the iterate tag in a jsp, it continually returns the correct number of records BUT displays the first record for all.

HQL that is produced:
Hibernate: select f410210_.LIITM as LIITM, f410210_.LIMCU as LIMCU,
f410210_.LILOCN as LILOCN, f410210_.LIPQOH as LIPQOH,
f410210_.LIPREQ as LIPREQ, f410210_.LIQWBO as LIQWBO,
f410210_.LIHCOM as LIHCOM, f410210_.LIPCOM as LIPCOM
from F41021 f410210_ where (f410210_.LILOCN=' ' )AND(f410210_.LIPQOH!=0 )AND(f410210_.LIITM
in(select f4101lb1_.IMITM from F4101LB f4101lb1_ where
(f4101lb1_.IMLITM='3408001504' )))

The output that is produced:
C 60 0 31999 0
C 60 0 31999 0
C 60 0 31999 0
C 60 0 31999 0
C 60 0 31999 0
C 60 0 31999 0

I have used MySQL to return a number of records, but can't seem to make it work with DB2400. Because of this I ask for your assistance.

thanks!


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

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.