-->
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: Too many statements (one to one relation)
PostPosted: Thu Jun 02, 2005 11:32 am 
Newbie

Joined: Thu Jun 02, 2005 10:26 am
Posts: 1
Hi

I have a big perfomance problem with hibernate...
simple example with 3 tables. the tables synonym and mofisPerson reference person with one to one relationships:
Synonom 1<--1 Person 1-->1 Mofisperson

if i try to search a person hibernates creates several statements for each record (!) that matches the query. If you have a look at the data below you see that the first statement should do the job but hibernet creats thousand of statements instaed. this takes a lot of time (~12 seconds for 600 records)

Is there a problem with the mapping. has anyone an idea?

Thanks for your support.

Greetings

Hibernate version:
2.1.7c

Mapping documents:
Person.hbm.xml
<hibernate-mapping>
<class
name="model.PersonExt"
table="Person"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="Person"
</meta>
<meta attribute="implement-equals" inherit="false">true</meta>

<id
name="perId"
type="java.lang.Integer"
column="perId"
>
<meta attribute="field-description">
@hibernate.id
generator-class="native"
type="java.lang.Integer"
column="perId"

</meta>
<generator class="native" />
</id>


<!-- uni-directional one-to-one association to Mofisperson -->
<one-to-one
name="mofisPerson"
class="model.MofispersonExt"
outer-join="auto"
property-ref="perId"
>
<meta attribute="field-description">
@hibernate.one-to-one
outer-join="auto"
property-ref="perId"
</meta>
</one-to-one>


<!-- uni-directional one-to-one association to Synonym -->
<one-to-one
name="synonym"
class="model.SynonymExt"
outer-join="auto"
property-ref="perId"
>
<meta attribute="field-description">
@hibernate.one-to-one
outer-join="auto"
property-ref="perId"
</meta>
</one-to-one>

</class>
</hibernate-mapping>


Mofisperson.hbm.xml:

<hibernate-mapping>
<class
name="model.MofispersonExt"
table="MofisPerson"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="MofisPerson"
</meta>
<meta attribute="implement-equals" inherit="false">true</meta>

<id
name="mofisPerId"
type="java.lang.Integer"
column="mofisPerID"
>
<meta attribute="field-description">
@hibernate.id
generator-class="native"
type="java.lang.Integer"
column="mofisPerID"

</meta>
<generator class="native" />
</id>

<!-- Associations -->

<property
name="perId"
column="perID"
type="java.lang.Integer"
length="10"
>
<meta attribute="field-description">
@hibernate.property
column="perID"
length="10"
</meta>
</property>

</class>
</hibernate-mapping>



Synonym.hbm.xml:

<hibernate-mapping>
<class
name="model.SynonymExt"
table="Synonym"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="Synonym"
</meta>
<meta attribute="implement-equals" inherit="false">true</meta>

<id
name="synonymId"
type="java.lang.Integer"
column="synID"
>
<meta attribute="field-description">
@hibernate.id
generator-class="native"
type="java.lang.Integer"
column="synID"

</meta>
<generator class="native" />
</id>

<!-- Associations -->

<property
name="perId"
column="perId"
type="java.lang.Integer"
length="10"
not-null="true"
>
<meta attribute="field-description">
@hibernate.property
column="perId"
length="10"
not-null="true"
</meta>
</property>

</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Configuration config = new Configuration();
config.configure();
SessionFactory sessionFactory = config.buildSessionFactory();
Session session = sessionFactory.openSession();
try {
List allPersons = (List)session.find("from PersonExt p order by p.name, p.vorname");
}catch{
.....
}

Full stack trace of any exception that occurs:

Name and version of the database you are using:
IBM DB2 7.1 (z/OS 1.4)

The generated SQL (show_sql=true):
select fields... from A02T.A02T009 personext0_ left outer join A02T.A02T010 mofisperso1_ on personext0_.SA1142C=mofisperso1_.SA1142C left outer join A02T.A02T071 synonymext2_ on personext0_.SA1142C=synonymext2_.SA1142C where personext0_.SA1142C=?

select fields... from A02T.A02T010 mofisperso0_ where mofisperso0_.SA1142C=?

select fields... from A02T.A02T071 synonymext0_ where synonymext0_.SA1142C=?

Debug level Hibernate log excerpt:


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.