-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Annotations one to one (onetoone) langsam
PostPosted: Tue Jan 05, 2010 7:22 am 
Newbie

Joined: Tue Jan 05, 2010 7:01 am
Posts: 1
Hi Leute,

das Hibernate fragt einzelne selects ab, anstatt über ein Statement mit Join abzufragen. Ich habe auch schon mit FetchType.EAGER ausprobiert. Hat ein Hibernate Profi rat?

Meine Java Klasse:
Code:
@Entity
class Bestellung{

BestellPosition position;
@OneToOne(FetchType.EAGER, optional=true)
@JoinColumn(name="transaktionsnr",   referencedColumnName="transaktionsnr")
public BestellPosition getPosition(){
    return position;
}


Die Abfrage habe ich über HQL und Criteria-API abgeschickt:

HQL:
Code:
List<Bestellung> list;
Query q=sess.createQuery("form Bestellung where kaufdatum>= :kaufdatum");
q.setParameter("kaufdatum",new Date());
list=q.list();


Criteria:
Code:
List<Bestellung> list;
Criteria crit=sess.createCriteria(Bestellung.class);
crit.add(Restrictions.eq("kaufdatum",new Date());
crit.setFetchMode(FetchMode.JOIN);
list=crit.list();



Gruß

Ricky


Top
 Profile  
 
 Post subject: Re: Hibernate Annotations one to one (onetoone) langsam
PostPosted: Fri Jan 15, 2010 9:35 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Dein Problem is bekannt unter dem Pseudonym: n+1 selects problem
Loesungsansaetze zu diesem Problem werden u.a. im Buch "Java Persistence with Hiberante" behandelt.


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