File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes advanced hibernate query issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "advanced hibernate query issue" Watch "advanced hibernate query issue" New topic
Author

advanced hibernate query issue

bob du
Greenhorn

Joined: Jun 22, 2012
Posts: 4
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 planSeq8_ ......

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 planSeq8_
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 planSeq8_
Manuel Petermann
Ranch Hand

Joined: Jul 19, 2011
Posts: 175

i have my pojo classes, hbm.xml files and my application runs fine
Might be but without them your whole situations is not likely to be solved by someone else, so please provide them!


Please correct my English.
bob du
Greenhorn

Joined: Jun 22, 2012
Posts: 4
the pojo class is a typical class with setter/getter methods.

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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: advanced hibernate query issue