[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Multiple entity level join fetch
norad2
do-not-reply at jboss.com
Mon Mar 24 17:28:20 EDT 2008
Say I have three entities, Owner, Cat, Kitten
| @Entity
| public class Owner {
| private Integer ownerId;
| private Set<Cat> cats = new HashSet<Cat>(0);
| .
| .
| .
| }
|
| @Entity
| public class Cat {
| private Integer catId;
| private Set<Kitten> kittens = new HashSet<Kitten>(0);
| .
| .
| .
| }
|
| @Entity
| public class Kitten {
| private Integer kittenId;
| .
| .
| .
| }
|
I want to be able to run one query that will join fetch all owners, cats and kittens
If I wanted to get all cats for all owners I could simply make the query
| select o from Owner o join fetch o.cats
|
I was trying to get the kittens at the same time with a query like this:
| select o from Owner o join fetch o.cats join fetch o.cats.kittens
|
but that doesn't work.
What would be the proper syntax to go multiple levels deep in a join fetch?
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4138596#4138596
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4138596
More information about the jboss-user
mailing list