Spring Hibernate开发点滴

本文总结了Spring开发中常见的错误及解决办法,包括初始化加载失败、Bean定义异常、数据完整性违规等问题,并对VO配置文件进行了详细解读。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在做开发过程中总会遇上些无厘头的错误,收集了些开发点滴,希望后来者不会踩上同一个陷阱,

1.Q:An error occured in the bean. Error Message is: Failed to lazily initialize a collection - no session or session was closed

A:未初始化加载

2. Q:org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name '' defined in resource [/WEB-INF/applicationContext-PoService.xml] of ServletContext: Bean class [com.itorgan.lherp.dao.impl.PoReceiveDAOImpl] not found; nested exception is java.lang.ClassNotFoundException: com.itorgan.lherp.dao.impl.PoReceiveDAOImpl

A:重启TOMCAT

3. Q:An error occured in the bean. Error Message is: An error occurred while evaluating custom action attribute "value" with value "${poItem.poItemNo}": Unable to find a value for "poItemNo" in object of class "com.itorgan.lherp.vo.PoReceiveItem" using operator "." (null)
A:变量${poItem.poItemNo}与VO com.itorgan.lherp.vo.PoReceiveItem 无法绑定


4. Q:org.springframework.dao.DataIntegrityViolationException: Hibernate operation: ORA-02291: integrity constraint (LH.FK_PO_RECEIVE_CUSTOMER_NO) violated - parent key not found
; nested exception is java.sql.BatchUpdateException: ORA-02291: integrity constraint (LH.FK_PO_RECEIVE_CUSTOMER_NO) violated - parent key not found

A:有对象未绑定

5. Q:vo配置文件解释

A:*大写的部分inverse="true"表示 ParentPO 本身不维护表之间的关系!,而由想反的一方 children来维护,
*CASCADE=“ALL”表示 无论是update,insert ,delete 都保持几连关系
*lazy="true"表示初始化父亲的时候不会把所有的儿子都从数据库中load进来。

6. Q:org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [] in task 'Hibernate operation'; nested exception is java.sql.SQLException: ORA-02289: sequence does not exist

A:VO中的sequence写错

7. Q:java.lang.ClassCastException: [Ljava.lang.String;

A:类型转换错误,数据库是否有重复记录
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值