-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate performance tunning
PostPosted: Thu May 20, 2004 10:06 am 
Newbie

Joined: Wed Apr 07, 2004 1:32 pm
Posts: 18
Hello,

I'am having problems with the sql generated by hibernate, I was expecting it to generate a sql with joins.

My mapping is:

<class name="Objeto" table="OBJETO">
<id name="id" column="OBJE_NR_ID">
<generator class="uuid.hex"/>
</id>
<map name="valoresData" table="VALORDATA" outer-join="true" lazy="false">
<key column="OBJE_NR_ID"/>
<index-many-to-many column="ATRI_NR_ID" class="Atributo"/>
<element column="VLDT_DT_VALOR" type="date" not-null="true"/>
</map>

If a load all instances of Objeto, it does the following:

select * from objeto

then for each objeto:

select * from valordata where objeto.id = ?

*** The sqls above are not the real ones, it's only for demonstrating what is happening.


Anyone can help me to tune this?

I want: select * from objeto, valordata where ...

Thanks,
Felipe;


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 10:11 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
hql:
Code:
from Object as obj left join fetch obj.valoresData where where objeto.id = ?


_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 11:05 am 
Newbie

Joined: Wed Apr 07, 2004 1:32 pm
Posts: 18
Thanks, it worked perfectly.

I have 3 maps in class Objeto. I tried this and did not work:

from Object as obj left join fetch obj.valoresData left join fetch obj.valoresTexto left join fetch obj.valoresNumerico where where objeto.id = ?

It didnt fetch the values correctly.

Thanks in advance,
Felipe;


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 12:40 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
only one collection can be fetch.... :(

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 1:45 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This is not a bad, but very good limitation.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 2:15 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
yes i know but for him it can be a bad new lol

fgoldin,
if more than one collection would be fetch, imagine the generated SQL....

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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