永发信息网

求助hibernate报错

答案:2  悬赏:0  手机版
解决时间 2021-03-16 22:19
求助hibernate报错
最佳答案
?. net.sf.hibernate.MappingException 当出现net.sf.hibernate.MappingException: Error reading resource:…异常时一般是因为映射文件出现错误。 当出现net.sf.hibernate.MappingException: Resource: … not found是因为XML配置文件没找到所致,有可能是放置目录不正确,或者没将其加入hibernate.cfg.xml中。2. net.sf.hibernate.PropertyNotFoundException 当出现net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property name in class …时,原因一般是因为XML映射文件中的属性与对应的Java类中的属性的getter或setter方法不一致。3. org.hibernate.id.IdentifierGenerationException 当出现org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save():异常时,一般是因为元素配置不正确,元素缺少其子元素的配置引起。 解决方案:元素映射了相应数据库表的主键字段,对其子元素,其中class的取值可以为increment、identity、sequence、hilo、native……等,更多的可参考hibernate参考文档,一般取其值为native 。具体可参考2.2.2.1小节。4. a different object with the same ide...?. net.sf.hibernate.MappingException 当出现net.sf.hibernate.MappingException: Error reading resource:…异常时一般是因为映射文件出现错误。 当出现net.sf.hibernate.MappingException: Resource: … not found是因为XML配置文件没找到所致,有可能是放置目录不正确,或者没将其加入hibernate.cfg.xml中。2. net.sf.hibernate.PropertyNotFoundException 当出现net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property name in class …时,原因一般是因为XML映射文件中的属性与对应的Java类中的属性的getter或setter方法不一致。3. org.hibernate.id.IdentifierGenerationException 当出现org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save():异常时,一般是因为元素配置不正确,元素缺少其子元素的配置引起。 解决方案:元素映射了相应数据库表的主键字段,对其子元素,其中class的取值可以为increment、identity、sequence、hilo、native……等,更多的可参考hibernate参考文档,一般取其值为native 。具体可参考2.2.2.1小节。4. a different object with the same identifier value was already associated with the session 当出现a different object with the same identifier value was already associated with the session时,一般是因为在hibernate中同一个session里面有了两个相同标识但是是不同实体。 有如下几种解决方案:(1)使用session.clean(),如果在clean操作后面又进行了saveOrUpdate(object)等改变数据状态的操作,有可能会报出"Found two representations of same collection"异常。(2)使用session.refresh(object),当object不是数据库中已有数据的对象的时候,不能使用session.refresh(object)因为该方法是从hibernate的session中去重新取object,如果session中没有这个对象,则会报错所以当你使用saveOrUpdate(object)之前还需要判断一下。(3)session.merge(object),Hibernate里面自带的方法,推荐使用。5. SQL Grammer Exception,Could not execute JDBC batch update 当出现SQL Grammer Exception,Could not execute JDBC batch update异常时,一般是由如下问题引起:(1)SQL语句中存在语法错误或是传入的数据有误;(2)数据库的配置不合法,或者说是配置有误。较容易出现的有数据表的映射文件(,hbm.xml文件)配置有误;Hibernate.cfg.xml文件配置有误;
全部回答

org.hibernate.mappingexception: entity class not found: dept

应该是 dept的bean 找不到,不知道 dept.class生成了没有呢.

我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
对自己喜欢的女孩要承诺什么?
酒泉市友邦养殖专业合作社我想知道这个在什么
达州火车人工售票几点钟上班
向马云发贴在哪里发
(女生进)我隔着裤子搓女友的B,她会什么感觉?
六婆串串香火锅(西园店)怎么去啊,有知道地址
格兰仕科龙哪个好
蓝海体育怎么去啊,有知道地址的么
常喝酸奶会导致缺钙吗?
我家英牛3个多月才7斤,怎么增肥啊
0.85*9.9乘法分配律
周杰伦代言优酸乳的那首歌叫什么名字?
泡水久了的胡萝卜吃了会怎么样
银行面试是不是真的一半面外貌
stand out or get out !这是什么意思呀
推荐资讯
我是一名搓澡工,我的职业是不是很可耻?
慎城酒行地址在什么地方,想过去办事
二十英寸电脑体积高多高宽多宽
麻地场地址在哪,我要去那里办事
我和女朋友一月一号做的爱请问什么时候才会怀
奎三村地址在什么地方,想过去办事
可心烘焙屋地址在哪,我要去那里办事
有没有可以提现的捕鱼
三点水加个然后的然怎么读
宜人坊这个地址在什么地方,我要处理点事
第一次和异性开房是什么体验
网上买的立邦漆都是假货吗?怎么辨识呢
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?