Hi everyone
So i started putting myself into hibernating yesterday.. allready got me a sleepless night (what an antilogy :) )
I figured out its a pretty cool thing tho i have still some questions.
I start with this one.. (others may follow :P)
Im about to read a 3 way fetch from the database, probably with hql. i did not see any other way to do it, tried the criteria way too, but i found myself limited to one fetch.
The table structure is like this:
Code:
League - 1:* - Team - 1:* - Player
In one case i need a complete loaded variant of those data.
so i tried this, for testing purpose:
Code:
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session session = sf.openSession();
String qry =
"from League as leag "
+ "left join fetch leag.teams "
+ "left join fetch leag.teams.players ";
Query query = session.createQuery(qry); // exception here..
The exception:
Code:
Exception in thread "main" org.hibernate.QueryException: illegal attempt to dereference collection [league0_.LeagueID.teams] with element property reference [players] [from ch.safv.service.business.League as leag left join fetch leag.teams left join fetch leag.teams.players ]
the entity objects look (shortened) like this:
Code:
public class League implements java.io.Serializable {
private Set<Team> teams = new HashSet<Team>(0);
...
}
public class Team implements java.io.Serializable {
private League league;
private Set<League > leagues = new HashSet<League>(0);
...
}
public class Player implements java.io.Serializable {
private Team team;
...
}
I was searching for hours now for a fine working method for this problem but i must admin i did not succeed ..
Any help in this would be greatly appreciated!
ps: if you need more code, i can post my config files too.. i just thought they might not be very interesting for this special problem.