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.
|