由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - ask a spring framework question
相关主题
hibernate高手求助想转Java开发,学什么framework最好找工作?
问一个Many to Many的设计问题Questions on EJB3 Persistence/Hibernate
spring/hibernate/struts .....问一个Collection Update的问题
求职业规划建议 (转载)java collections framework 是啥?
新手起步,找工作的问题a garbage collection question
请问公司里用Java主要干啥?你们有人测试过这种语法么?
请教一下怎么学习java framework,怎么找java工作java为啥这么多framework
Netflix用什么Java Framework (转载)Click web framework is interesting
相关话题的讨论汇总
话题: student话题: studentid话题: courses话题: public话题: studentdao
进入Java版参与讨论
1 (共1页)
s*****p
发帖数: 5342
1
I user HibernateTemplate to use hibernate. However, I met a problem on
session lost or session close.Basically, I did:
Database relationship: 1 student -> n courses
public class Student {
String studentId;
Collection courses;
...
public Collection getCourses(){
return courses;
}
}
public class StudentDAO {
public Student getStudent(String studentId) {
return getHibernateTemplate().get(Student.class, studentId);
}
}
I can get Student object through StudentDAO.
Student student = (S
h**d
发帖数: 474
2
are you using lazy loading?
Your hibernate mapping file will help too

【在 s*****p 的大作中提到】
: I user HibernateTemplate to use hibernate. However, I met a problem on
: session lost or session close.Basically, I did:
: Database relationship: 1 student -> n courses
: public class Student {
: String studentId;
: Collection courses;
: ...
: public Collection getCourses(){
: return courses;
: }

m******t
发帖数: 2416
3
The session is obtained in HibernateTemplate.get(), and released right away
before the method returns. You need to either access getCourses within the
same transaction, or use an OpenSessionInViewFilter/Interceptor - or disable
lazy loading for 'courses' in your mapping (which is usually not a good
idea).

【在 s*****p 的大作中提到】
: I user HibernateTemplate to use hibernate. However, I met a problem on
: session lost or session close.Basically, I did:
: Database relationship: 1 student -> n courses
: public class Student {
: String studentId;
: Collection courses;
: ...
: public Collection getCourses(){
: return courses;
: }

1 (共1页)
进入Java版参与讨论
相关主题
Click web framework is interesting新手起步,找工作的问题
请推荐一下RESTful WS Framework请问公司里用Java主要干啥?
一大堆Java的 web app framework,学那个最有用啊请教一下怎么学习java framework,怎么找java工作
java问题:如何match两个正规表达式Netflix用什么Java Framework (转载)
hibernate高手求助想转Java开发,学什么framework最好找工作?
问一个Many to Many的设计问题Questions on EJB3 Persistence/Hibernate
spring/hibernate/struts .....问一个Collection Update的问题
求职业规划建议 (转载)java collections framework 是啥?
相关话题的讨论汇总
话题: student话题: studentid话题: courses话题: public话题: studentdao