-->
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 query issue
PostPosted: Mon Jun 25, 2012 1:27 pm 
Newbie

Joined: Mon Jun 25, 2012 1:13 pm
Posts: 2
i have my pojo classes, hbm.xml files and my application runs fine. but on the console, the hibernate generated queries is doing some kind of loop or repeat of the queries.

console shows something like this (first 8 rows is fine, but after is where the repeats starts. i want to know why it is doing this and how do i fix this issue.) some info that may help, at the end of each hibernate queries are left inner joins and they have either one-to-one or one-to-many mappings (this code was written using hibernate 2.0)

Hibernate: select planprefac0_.planSeq as planSeq ......
Hibernate: select planadl0_.planSeq as planSeq7_ ......
Hibernate: select planclaima0_.planSeq as planSeq7_ ......
Hibernate: select company0_.code as code0_ ......
Hibernate: select statecode0_.code as code0_ ......
Hibernate: select sexcode0_.code as code0_ ......
Hibernate: select planprefac0_.planSeq as planSeq7_ ......
Hibernate: select planprefac0_.planSeq as planSeq7_ ......

Hibernate: select planadl0_.planSeq as planSeq7_
Hibernate: select planclaima0_.planSeq as planSeq7_
Hibernate: select statecode0_.code as code0_
Hibernate: select planprefac0_.planSeq as planSeq7_
Hibernate: select planprefac0_.planSeq as planSeq7_
Hibernate: select planadl0_.planSeq as planSeq7_
Hibernate: select planclaima0_.planSeq as planSeq7_
Hibernate: select planprefac0_.planSeq as planSeq7_
Hibernate: select planprefac0_.planSeq as planSeq7_
Hibernate: select planadl0_.planSeq as planSeq7_
Hibernate: select planclaima0_.planSeq as planSeq7_
Hibernate: select planprefac0_.planSeq as planSeq7_
Hibernate: select planprefac0_.planSeq as planSeq7_


Top
 Profile  
 
 Post subject: Re: hibernate query issue
PostPosted: Tue Jun 26, 2012 2:33 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I guess the problem may get resolved if you declare the one-to-one relations lazy.


Top
 Profile  
 
 Post subject: Re: hibernate query issue
PostPosted: Tue Jun 26, 2012 10:00 am 
Newbie

Joined: Mon Jun 25, 2012 1:13 pm
Posts: 2
because this is hibernate 2.0, there is not such attribute that will allow me to set the one to one mappings to lazy. is there another way?

here is a snippet of one of the hbm.xml file in case this may help

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >


<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="hibernate.PlanPreface"
table="Plan_Preface"
>
<cache usage="read-write"/>

<id
name="planSeq"
type="java.lang.Long"
column="planSeq"
>
<generator class="native" />
</id>

<property
name="planCode"
type="java.lang.String"
column="planCode"
not-null="true"
length="20"
/>

<!-- Associations -->
<!-- bi-directional one-to-many association to PlanBenefit -->
<bag
name="planBenefits"
lazy="true"
inverse="true"
cascade="all"
>
<key>
<column name="planSeq" />
</key>
<one-to-many
class="hibernate.PlanBenefit"
/>
</bag>


<!-- bi-directional one-to-one association to PlanAdl -->
<one-to-one
name="planAdl"
class="hibernate.PlanAdl"
outer-join="auto"
cascade="delete"
/>

<many-to-one name="insproCompany" class="hibernate.Company" insert="false" update="false">
<column name="company" />
</many-to-one>

<many-to-one name="stateCode" class="hibernate.StateCode" insert="false" update="false">
<column name="state" />
</many-to-one>

<many-to-one name="sexCode" class="hibernate.SexCode" insert="false" update="false">
<column name="gender" />
</many-to-one>

<!-- bi-directional one-to-one association to PlanPrefaceCoverage -->
<one-to-one
name="coverage"
class="hibernate.PlanPrefaceCoverage"
cascade="all"
/>
<!-- bi-directional one-to-one association to PlanPrefaceMaximum -->
<one-to-one
name="maximum"
class="hibernate.PlanPrefaceMaximum"
cascade="all"
/>
</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.