-->
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: Why does Hibernate ignore my fetch annotations?
PostPosted: Sat Jul 28, 2012 8:49 am 
Beginner
Beginner

Joined: Tue Jul 03, 2007 8:47 am
Posts: 46
Hi,

I've created a hibernate entity which I annotated to get some relations join-fetched:
Code:
@Entity(name = "Startkladde")
public class KladdenEntry implements Cloneable, IDEntity {
    @Id
    public Integer id;

    @org.hibernate.annotations.Index(name = "kladde_flugzeug_index")
    @Fetch(FetchMode.JOIN)
    @ManyToOne
    @JoinColumn(name = "flugzeugid", nullable = true, columnDefinition = "INTEGER")
    Flugzeug flugzeug;


yet when I execute a query, I see "flugzeug" is loaded via a seperate query:
Code:
session.createQuery("FROM Startkladde").setMaxResults(10).list();

results in:
Hibernate: select kladdenent0_.id as id4_, kladdenent0_.aktuellerF .... //loads the requested entity
Hibernate: select flugzeug0_.id as id2_2_, flugzeug0_.ansprechParnt ... //loads the ManyToOne related entity seperate


If I execute a criteria based query instead:
Code:
session.createCriteria(KladdenEntry.class).setMaxResults(10).list();

.... I get a nice join query as requested.

Any idea whats going on here?

Thank you in advance, Clemens


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.