could not initialize proxy - no Session 求解!!
我没有启动服务器,在编写后台的时候碰到这样的问题怎么解决啊,找了很久大部分是在服务器上配置OpenSessionInViewFilter
我在web.xml文件里面也配置了。还是报 could not initialize proxy - no Session
小弟初学这个,确实解决不了,望各位大哥帮忙!
谢谢!!!
DAO层代码:
public void delDepartment(Department department){
this.getHibernateTemplate().delete(department);
}
service 层代码:
public boolean delDepartmentS(int departmentid){
departmentStatic = departDao.findDepartmentById(departmentid);
Set<Department> set = new HashSet<Department>();
set = departmentStatic.getChildDepartment();
if(set.size()!= 0)
{
System.out.println("处理有子机构的情况---");
return false;
}else
{
departDao.delDepartment(departmentStatic);
return true;
}
}
测试代码:
BeanFactory factory = new ClassPathXmlApplicationContext("applicationContext-*.xml");
IDepartmentService service = (DepartmentServiceImpl)factory.getBean("departService");
service.delDepartmentS(2);