Hello,
I have a quite common class structure consistsing of the classes Article, SoldArticle, Sell and Bill:
Code:
public class Article {}
public class SoldArticle {
@ManyToOne(fetch=FetchType.EAGER)
@Fetch(FetchMode.JOIN)
@JoinColumn(name = "artikelid", columnDefinition = "INTEGER")
Artikel artikel;
}
public class Sell {
@OneToMany(mappedBy = "verkauf", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@Fetch(FetchMode.SUBSELECT)
private List<SoldArticle> artikel = new ArrayList<SoldArticle>();
@ManyToOne
@Fetch(FetchMode.JOIN)
@JoinColumn(name = "rechnungsid", columnDefinition = "INTEGER")
private Bill bill;
}
What I would like to do now, is to load all SoldArticles which are assigned to a certain Bill:
list = session.createQuery("FROM SoldArticle va WHERE va.sell.bill.id=xy").list();
Hibernate creates all joins required for the WHERE statement, however it refuses to fetch the artikel-column of the SoldArtikle class.
I also tried to explicitly specify the JOINS in the HQL query, but didn't have a lot success. All I get are javaassist proxy instances :/
Any idea why Hibernate refuses to load SoldArticle.artikel with a JOIN?
Thank you in advance, Clemens