-->
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.  [ 3 posts ] 
Author Message
 Post subject: @Fetch (FetchMode.JOIN)
PostPosted: Sat Sep 02, 2006 9:50 pm 
Newbie

Joined: Mon Aug 28, 2006 12:13 pm
Posts: 4
Hi All,
In class User there is a roles collection:

@ManyToMany(fetch = FetchType.EAGER)
@Fetch (FetchMode.JOIN)
@LazyCollection ( LazyCollectionOption.FALSE )
@JoinTable(
name="authorities",
joinColumns = @JoinColumn( name="user_id") ,
inverseJoinColumns = @JoinColumn( name="role_id",unique=false)
)
public Set<Role> getRoles() {
return roles;
}

at present time hibernate load roles in 2 selects.

Hibernate:
select
user0_.id as id7_,
user0_.username as username7_,
user0_.cinfo_id as cinfo6_7_,
user0_.pinfo_id as pinfo7_7_,
user0_.lastupdate as lastupdate7_,
user0_.address_id as address8_7_,
user0_.enabled as enabled7_,
user0_.password as password7_
from
users user0_
where
user0_.username=?

Hibernate:
select
roles0_.user_id as user1_1_,
roles0_.role_id as role2_1_,
role1_.id as id6_0_,
role1_.name as name6_0_,
role1_.description as descript3_6_0_
from
authorities roles0_
left outer join
authority role1_
on roles0_.role_id=role1_.id
where
roles0_.user_id=?


Is there any way to force it to use join ? @Fetch (FetchMode.JOIN) didn't change anything...


thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 04, 2006 7:10 am 
Beginner
Beginner

Joined: Sun Jan 22, 2006 6:56 am
Posts: 29
How did you load the object (HQL, Criteria, by ID)? Each load method has different behavior, e.g. HQL ignores the fetch method described in the metadata.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 11, 2006 8:55 am 
Beginner
Beginner

Joined: Sat Oct 08, 2005 2:13 am
Posts: 47
Hi

I think you should use BatchSize


------------------------
Mohammad Norouzi


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.