50,523
社区成员
发帖
与我相关
我的任务
分享
Struts has detected an unhandled exception:
Messages:
could not initialize proxy - no Session
Error reading 'nameCn' on type entity.Position_$$_javassist_5
An exception occurred processing JSP page /WEB-INF/page/index.jsp at line 33 30: 31:
32:${employee.position.nameCn}
Stacktrace:
File: org/hibernate/proxy/AbstractLazyInitializer.java
Line number: 132
public String toIndex(){
employee = (Employee)ActionContext.getContext().getSession().get("employee");
return "toIndex";
}
public String login(){
employee = ls.queryLogin(employee);
if(employee!=null){
ActionContext.getContext().getSession().put("employee", employee);
return "reIndex";
}
return "toLogin";
}
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
public class Employee
private String sn;
private Position position;
private Department department;
private String name;
private String password;
private String status;
public class Position
private Integer id;
private String nameCn;
private String nameEn;
private Set employees = new HashSet(0);
[/quote]
一对多映射的配置贴出来[/quote]
Employee.hbm.xml
<many-to-one name="position" class="entity.Position" fetch="select">
<column name="POSITION_ID" >
<comment>职位ID</comment>
</column>
</many-to-one>
Position.hbm.xml
<set name="employees" inverse="true">
<key>
<column name="POSITION_ID" >
<comment>职位ID</comment>
</column>
</key>
<one-to-many class="entity.Employee" />
</set>
public class Employee
private String sn;
private Position position;
private Department department;
private String name;
private String password;
private String status;
public class Position
private Integer id;
private String nameCn;
private String nameEn;
private Set employees = new HashSet(0);
[/quote]
一对多映射的配置贴出来
public class Employee
private String sn;
private Position position;
private Department department;
private String name;
private String password;
private String status;
public class Position
private Integer id;
private String nameCn;
private String nameEn;
private Set employees = new HashSet(0);