-->
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: Hibernate Lazy issue or where clause issue..help please..
PostPosted: Mon May 31, 2010 11:56 pm 
Newbie

Joined: Mon May 31, 2010 11:00 pm
Posts: 3
Hi,
I have below hibernate issue. Here is my configration.

Code:
   
<class name="org.xxx.xxx.xx.data.po.QwRptDefn" table="QW_RPT_DEFN">
    ........
    <set name="prntClmns" lazy="true" inverse="true" order-by="sqnc_num" where="srt_only_sw=&apos;N&apos;">
      <key>
        <column name="RPT_NUM"/>
      </key>
      <one-to-many class="org.xxxx.xx.xx.data.po.QwRptClmn"/>
    </set>
</class>

<class name="org.xxxx.xx.xx.data.po.QwRptClmn" table="QW_RPT_CLMN">
   ........
  <property name="srtOnlySw" type="yes_no" column="SRT_ONLY_SW" not-null="true" length="1"/>
</class>





// trying to get some records for origRptDefn.
for (Iterator it = origRptDefn.getPrntClmns().iterator(); it.hasNext();) {
hibernate query generates here for origRptDefn.getPrntClmns() correctly with srt_only_sw='N'
}

// trying to insert some records into QwRptClmn for qwRptDefn

for (Iterator it = qwRptDefn.getPrntClmns().iterator(); it.hasNext();) {
// getPrntClms suppose to get only records srt_only_sw is 'N' as defined in hbm file.
// I wounder this loop is geeting the records srt_only_sw is 'Y' also, where this record got saved just above.
// Tough I specified hibernate lazy is true, hibernate query is not generated here, but it got generated at the begining on origRptDefn.getPrntClmns(). I am not worry about this, but I am getting wrong record with srt_only_sw='Y' on qwRptDefn.getPrntClmns().Appreciate your help here.Thanks in advance
}
[/code]
Appreciate your help here.
Thanks in advance


Last edited by dileep24p on Tue Jun 01, 2010 6:16 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Hibernate Lazy issue or where clause issue..help please..
PostPosted: Tue Jun 01, 2010 1:07 pm 
Newbie

Joined: Mon May 31, 2010 11:00 pm
Posts: 3
I have little more information to share.
When tried to use qwRptDefn.getPrntClmns() initially, the below query generated fine with srt_only_sw='N'


Code:
statement|select prntclmns0_.RPT_NUM....  from QW_RPT_CLMN prntclmns0_ left outer join QW_VW_CLMN qwvwclmn1_ on prntclmns0_.VW_CLMN_ID=qwvwclmn1_.VW_CLMN_ID left outer join QW_SUBJ_CLMN_VW qwsubjclmn2_ on qwvwclmn1_.SUBJ_ID=qwsubjclmn2_.SUBJ_ID and qwvwclmn1_.CLMN_NAME=qwsubjclmn2_.CLMN_NAME where prntclmns0_.RPT_NUM=-49398 and prntclmns0_.srt_only_sw='N' order by prntclmns0_.sqnc_num


After this, i have some java code(in my previous post) that inserts into QW_RPT_CLMN. Now when i try to access the same qwRptDefn.getPrntClmns(), below query generates with out srt_only_sw='N' and order by sqnc_num.
Code:
statement|select qwrptclmn0_.RPT_NUM......  from QW_RPT_CLMN qwrptclmn0_ where (rpt_num='-49398' )


This is the reason I have wrong size of data with out having filtered with srt_only_sw='N'.
This issue happens only when my java code inserts records into QW_RPT_CLMN(as stated above). I wounder what is going on. Appreciate if some one have help in this, and i can provide more info if required.

Thanks a bunch.


Top
 Profile  
 
 Post subject: Re: Hibernate Lazy issue or where clause issue..help please..
PostPosted: Tue Jun 01, 2010 6:18 pm 
Newbie

Joined: Mon May 31, 2010 11:00 pm
Posts: 3
This is resolved. Thanks for looking in to this.
There are two addPrntClmns getting called based on situation. One is not correctly implemented and after fixing it works. Thanks again.

Dileep


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.