【发布时间】:2012-04-01 02:28:46
【问题描述】:
org.hibernate.LazyInitializationException: 延迟初始化角色集合失败:com.siteadmin.domain.HostSite.sectionList,没有会话或会话被关闭
主机站点
@Entity
@Table(name="hs")
public class HostSite {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@OneToMany(mappedBy="hostSite")
private List<HostSiteSection> sectionList;
主机站点部分
@Entity
@Table(name="hsst")
public class HostSiteSection {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="hsid")
private HostSite hostSite;
控制器
screenObject.setSectionList(hostSite.getSectionList());
JSP
<c:if test="${screenObject!=null && screenObject.getSectionList()!=null}">
<c:forEach items="${screenObject.getSectionList()}" var="section">
<tr>
<td><a href="../hostSiteSection/${section.id}" target="_blank">${section.id}</a></td>
<td><a href="../hostSiteSection/${section.id}" target="_blank">${section.name}</a></td>
<td>${section.order}</td>
</tr>
</c:forEach>
</c:if>
它在哪里分崩离析?在控制器还是jsp?原因是什么?急切和懒惰我都试过了。
【问题讨论】: