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>