有2个实体
User Role
关系是多对多
hibernate生成的sql如下
select *
from public.user user0_
inner join user_role roles1_ on user0_.id=roles1_.user_id
inner join public.role role2_ on roles1_.role_id=role2_.id
where user0_.delflg='0'
order by user0_.id asc
每次执行都会报
WARN: HHH000104: firstResult/maxResults specified with collection fetch; applying in memory!
上网查了下,并没有具体的解决办法
只是解释了一下,产生的原因
我想问有没有什么具体的解决方案啊?
可以根治这个问题
或者说是因为我写的hql不对,所以才导致这个问题的
想听听大家对这个问题的见解
-------------------------分割线----------------------
在贴下hql
from User as user
inner join fetch user.roles as roles
在贴下实体类的关系代码
public class User{
@ManyToMany
@JoinTable(
name="user_role",
joinColumns=@JoinColumn(name="user_id"),
inverseJoinColumns=@JoinColumn(name="role_id"))
private List<Role> roles;
}
public class Role extends Page{
@ManyToMany
@JoinTable(
name="role_perm",
joinColumns=@JoinColumn(name="role_id"),
inverseJoinColumns=@JoinColumn(name="perm_id"))
@JsonIgnore
private List<Perm> perms;
}