相关疑难解决方法(0)

com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValuesForModel上的org.hibernate.LazyInitializationException

尽管FetchType.EAGERJOIN FETCH,我得到一个LazyInitalizationException,同时增加一些对象,以一个@ManyToMany通过收集JSF UISelectMany组件,如我的情况<p:selectManyMenu>.

@Entity IdentUser,有FetchType.EAGER:

@Column(name = "EMPLOYERS")
@ManyToMany(fetch = FetchType.EAGER, cascade= CascadeType.ALL)
@JoinTable(name = "USER_COMPANY", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "COMPANY_ID") })
private Set<Company> employers = new HashSet<Company>();
Run Code Online (Sandbox Code Playgroud)

@Entity Company,有FetchType.EAGER:

@ManyToMany(mappedBy="employers", fetch=FetchType.EAGER)
private List<IdentUser> employee;
Run Code Online (Sandbox Code Playgroud)

JPQL,包含JOIN FETCH:

public List<IdentUser> getAllUsers() {
    return this.em.createQuery("from IdentUser u LEFT JOIN FETCH u.employers WHERE u.enabled …
Run Code Online (Sandbox Code Playgroud)

jsf jpa lazy-loading eager-loading selectmanymenu

14
推荐指数
2
解决办法
2748
查看次数

标签 统计

eager-loading ×1

jpa ×1

jsf ×1

lazy-loading ×1

selectmanymenu ×1