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