為什么視頻中事務(wù)不用調(diào)用begin()方法直接提交就可以運(yùn)行,我的卻提示事務(wù)沒有成功打開?我百度了下,事務(wù)提交之前先調(diào)用事務(wù)的begin()方法就完美運(yùn)行了?
2016-08-04
在 class Grade 中,
Set<Student> students;//為初始化
//改為
Set<Student> students =new HashSet<Student>();
這樣 g.getStudents() 已初始化。
Set<Student> students;//為初始化
//改為
Set<Student> students =new HashSet<Student>();
這樣 g.getStudents() 已初始化。
2016-08-04
@qq_夜_28 因?yàn)閙ain方法是靜態(tài)的,而靜態(tài)方法中只能使用靜態(tài)方法
2016-07-30
本節(jié)出現(xiàn)的問(wèn)題:1.使用grade.getStudents().add(stu1);拋出異常。辦法:使用前調(diào)setStudetns事例化集合:grade.setStudents( new HashSet<Student>());2.在findStudentsByGrade()方法中出現(xiàn)空指針異常,檢查后發(fā)現(xiàn)是查詢grade返回的是null。解決辦法:將hibernate.cfg.xml中的<property name="hbm2ddl.auto">create</property>的create修改為update 要不然每次數(shù)據(jù)庫(kù)操作都會(huì)創(chuàng)建新表會(huì)覆蓋你原來(lái)的表,導(dǎo)致已插入的數(shù)據(jù)丟失。
2016-07-26
最新回答 / 錫雋
感覺報(bào)空指針的情況很多 , 我遇到的 mapping里沒寫package屬性會(huì)報(bào)空指針 , Set后面沒有寫new HashSet也會(huì)報(bào)空指針 。。? 好尷尬
2016-07-26
在findStudentsByGrade()方法中出現(xiàn)空指針異常,在Grade的構(gòu)造方法里,初始化學(xué)生類
public Grade(String gname, String gdesc) {
super();
this.students = new HashSet<Student>();
this.gname = gname;
this.gdesc = gdesc;
}
public Grade(String gname, String gdesc) {
super();
this.students = new HashSet<Student>();
this.gname = gname;
this.gdesc = gdesc;
}
2016-07-25
給變量起了個(gè)名字group,程序崩了,搞了半天才想起group是MySQL的關(guān)鍵字( ′_>`)
2016-07-25
初始化一下
Grade g=new Grade("Java二班", "Java軟件開發(fā)二班");
g.setStudents(new HashSet<Student>());
Grade g=new Grade("Java二班", "Java軟件開發(fā)二班");
g.setStudents(new HashSet<Student>());
2016-07-23
inverse="true" 把維護(hù)的權(quán)限給了多的一方,1的一方根本就不維護(hù)了,怎么可能去更新多的一方的表,也是醉了
2016-07-22