- 浏览: 377189 次
文章分类
最新评论
-
tedeum:
美帝人民不为钱写代码是因为万恶的资本主义社会保障制度
读《20个月赚130亿》有感 -
novembersky:
还好你没相信那个大饼
谁坑了程序员的职业道德?送给初入职的码农,和宣传奴性的领导。 -
禀圣含华:
也不要着急进一家公司,就因为那公司急着招人。。急着招人背后又是 ...
谁坑了程序员的职业道德?送给初入职的码农,和宣传奴性的领导。 -
haohao-xuexi02:
每个码奴辛辛苦苦最后,还不能干脆的走。。各种被坑。。。
找工作 ...
谁坑了程序员的职业道德?送给初入职的码农,和宣传奴性的领导。 -
hot002:
BuN_Ny 写道真实项目中的6种人:1.怂恿者2.批评者3. ...
一个优秀创业团队需要的6种人
(转)hibernate 注解的问题(异常)集合
1,问题:An AnnotationConfiguration instance is required to use <mapping class="vo.Student"/>
解答:错误:SessionFactory factory = new Configuration().configure().buildSessionFactory(); //这句是用映射文件为xml的
<wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">正确:SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory();//这句是用于注解的</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">2,问题:@OneToOne or @ManyToOne on vo.StuCour.student references an unknown entity: vo.Student</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">解答:错误原因(1):配置文件没有添加映射</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">方法:加上配置:在hibernta.hfg.xml<mapping class="vo.Student"/></span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">错误原因(2):在实体类public class ClassName上面没有加实体注解,</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">方法:加上注解:@Entity</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">@Table(name = "Student", catalog = "sms")</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">3,问题:mappedBy reference an unknown target entity property: vo.StuCour.stuCours</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">错误原因:在one-to-many注解配置: @OneToMany (mappedBy = "StuCour"),mappedBy指向的是要关联的属性,而不是要关联的类,</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">如果这样配置,hibernate则会找vo.StuCour类下面的stuCours属性。但实际上没有这个属性,就会报上面的异常</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">方法:指定到实际关联的属性:即:@OneToMany (mappedBy = "courseId")</span> </wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
解答:错误:SessionFactory factory = new Configuration().configure().buildSessionFactory(); //这句是用映射文件为xml的
<wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">正确:SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory();//这句是用于注解的</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">2,问题:@OneToOne or @ManyToOne on vo.StuCour.student references an unknown entity: vo.Student</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">解答:错误原因(1):配置文件没有添加映射</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">方法:加上配置:在hibernta.hfg.xml<mapping class="vo.Student"/></span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">错误原因(2):在实体类public class ClassName上面没有加实体注解,</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">方法:加上注解:@Entity</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">@Table(name = "Student", catalog = "sms")</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">3,问题:mappedBy reference an unknown target entity property: vo.StuCour.stuCours</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">错误原因:在one-to-many注解配置: @OneToMany (mappedBy = "StuCour"),mappedBy指向的是要关联的属性,而不是要关联的类,</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">如果这样配置,hibernate则会找vo.StuCour类下面的stuCours属性。但实际上没有这个属性,就会报上面的异常</span><br style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"></span><wbr style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px"><span style="color:rgb(70,70,70); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:21px">方法:指定到实际关联的属性:即:@OneToMany (mappedBy = "courseId")</span> </wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
相关推荐
如果使用延迟加载,在读“多端”列表时会出异常,立即加载在得到多端时,是一个空集合(集合元素为0)。 * “一端”配置 * @OneToMany(mappedBy="“多端”的属性") * public List<“多端”类> get“多端”列表(){...
5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent ...
后台全注解式的开发(除了必要的spring和hibernate的xml配置以外) 03. 后台通过自定义注解结合一个访问拦截器实现整个系统的权限控制 04. 系统前台采用全采用的Html+jQuery开发 05. 系统前台与后台的交互全部使用 ...
5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent ...
5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent ...
5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent ...
5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent collections) ...
5.4.2. 使用 JDK 5.0 的注解(Annotation) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent collections) 6.2. 集合映射( Collection mappings ) 6.2.1. 集合外键(Collection foreign keys) 6.2.2. 集合...
6.4.2. 使用 JDK 5.0 的注解(Annotation) 7. 集合类(Collections)映射 7.1. 持久化集合类(Persistent collections) 7.2. 集合映射( Collection mappings ) 7.2.1. 集合外键(Collection foreign keys) 7.2.2. ...
1. Hibernate入门 1.1. 前言 1.2. 第一部分 - 第一个Hibernate应用程序 1.2.1. 第一个class 1.2.2. 映射文件 1.2.3. Hibernate配置 1.2.4. 用Ant构建 1.2.5. 启动和辅助类 1.2.6. 加载并存储对象 1.3. 第...
5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent ...
6.4.2. 使用 JDK 5.0 的注解(Annotation) 7. 集合类(Collections)映射 7.1. 持久化集合类(Persistent collections) 7.2. 集合映射( Collection mappings ) 7.2.1. 集合外键(Collection foreign keys) 7.2.2. ...
5.4.2. 使用 JDK 5.0 的注解(Annotation) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent collections) 6.2. 集合映射( Collection mappings ) 6.2.1. 集合外键(Collection foreign keys) 6.2.2. 集合...
使用 JDK 5.0 的注解(Annotation) 7. 集合类(Collections)映射 7.1. 持久化集合类(Persistent collections) 7.2. 集合映射( Collection mappings ) 7.2.1. 集合外键(Collection foreign keys) 7.2.2. 集合...
5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent collections) ...
Java基础:变量、数据类型、运算符、条件语句、循环语句、数组、集合、异常处理等 面向对象:类、继承、多态、包、接口、抽象类、泛型等 异常处理:try-catch-finally、异常分类及处理、自定义异常等 线程:线程创建...
如果使用注解还需添加hibernate-annotations-3.4.0.GA包: 11.hibernate-annotations.jar 12.ejb3-persistence.jar 13.hibernate-commons-annotations.jar json需要的jar包: 1.commons-beanutils-1.8.2.jar 2....
Seam - 语境相关的组件[满江红20071230]............................................................................................................................ 1 Java EE 框架...........................
8.8 映射异常视图 312 8.8.1 问题 312 8.8.2 解决方案 312 8.8.3 工作原理 312 8.9 用@Value在控制器中赋值 314 8.9.1 问题 314 8.9.2 解决方案 314 8.9.3 工作原理 314 8.10 用控制器处理表单 ...