-->
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.  [ 3 posts ] 
Author Message
 Post subject: SQL to HQL conversion
PostPosted: Thu Apr 09, 2009 4:35 am 
Newbie

Joined: Thu Apr 09, 2009 4:30 am
Posts: 3
Hi,
I am struggling to convert the following SQL to HQL. Please help me.

select
lps.plp_log_pos_type logical_position
,si.iv_manuf_model_version model_version
,si.iv_sysid iv_sysid
,lps.plp_card_mandatory mandatory
,lps.display_order display_order
,si.sysid record_id
,si.iv_sysid shelf_iv_sysid
,lps.plp_log_pos_type shelf_position
,ss.scm_sysid scm_sysid
from
logical_positions lps
,shelf_instances si
,scheme_shelves ss
where
lps.sne_id = <sne_id>
and lps.shelf_log_pos = 'Y'
and si.lps_sne_id(+) = lps.sne_id
and si.lps_plp_log_pos_type(+) = lps.plp_log_pos_type
and ss.shelf_lps_sne_id(+) = si.lps_sne_id
and ss.shelf_lps_plp_log_pos_type(+)= si.lps_plp_log_pos_type
and ss.shelf_id(+) = si.sysid
Thanks in advance
ramesh


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 09, 2009 9:18 am 
Beginner
Beginner

Joined: Wed Oct 03, 2007 4:10 am
Posts: 46
You have to post the mappings for the tables involved in the query too in order to get help. You can also simplify the query to something you really don;t know how to write in hql.

_________________
Alexandru BARBAT


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 14, 2009 11:36 am 
Newbie

Joined: Thu Apr 09, 2009 4:30 am
Posts: 3
Thanks Alexandru
Find the simplified SQL and configuration

select
lps.plp_log_pos_type logical_position
,si.sysid record_id
,si.iv_sysid shelf_iv_sysid
,lps.plp_log_pos_type shelf_position
from
logical_positions lps
,shelf_instances si
where
lps.sne_id = <sne_id>
and lps.shelf_log_pos = 'Y'
and si.lps_sne_id(+) = lps.sne_id
and si.lps_plp_log_pos_type(+) = lps.plp_log_pos_type


for lps

<hibernate-mapping default-access="field">
<class name="com.bt.hibernate.LogicalPositions" table="logical_positions" >
<composite-id name="logicalPositionsPK" class="com.bt.hibernate.LogicalPositionsPK">
<key-property name="sneId" column="SNE_ID"/>
<key-property name="plpLogPosType" column="PLP_LOG_POS_TYPE"/>
<key-property name="plpDxcPosNo" column="PLP_DXC_POS_NO"/>
</composite-id>
<property name="shelfLogPos" column="SHELF_LOG_POS"/>
<property name="plpCardMandatory" column="PLP_CARD_MANDATORY"/>
<property name="displayOrder" column="DISPLAY_ORDER" />
</class>

</hibernate-mapping>

for si:
<hibernate-mapping default-access="field">
<class name="com.bt.hibernate.ShelfInstances" table="shelf_instances" >
<id name="sysId" column="SYSID" />
<property name="ivManufModelVersion" column="iv_manuf_model_version"/>
<property name="ivSysId" column="iv_sysid"/>
<property name="lpsSneId" column="lps_sne_id"/>
<property name="lpsPlpLogPosType" column="lps_plp_log_pos_type" />
</class>
</hibernate-mapping>




Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.