-->
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: Double Left join - cannot get it to work..
PostPosted: Sun Jan 17, 2010 7:45 am 
Newbie

Joined: Sun Jan 17, 2010 7:22 am
Posts: 1
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.


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.