Could not execute JDBC batch update/ORA-01779: 无法修改与非键值保存表对应的列

来源:互联网 发布:手机外卖软件咋接单 编辑:程序博客网 时间:2024/06/05 21:24

<br>instance: /opt/weblogic/user_projects/domains/edi
<br>ErrorMessage: java.sql.BatchUpdateException: ORA-01779: 无法修改与非键值保存表对应的列

 at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:629)
 at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9467)
 at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:211)
 at weblogic.jdbc.wrapper.PreparedStatement.executeBatch(PreparedStatement.java:210)
 at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
 at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
 at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
 at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:41)
 at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:954)
 at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1121)
 at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:94)
 at com.sinosure.sol.persistence.dao.BaseDAOImpl.batchUpdate(BaseDAOImpl.java:376)
 at com.sinosure.sol.service.edi.Common.domestic.EdiDomReceiptApplyServiceImpl.doChangeDomDeclareApply(EdiDomReceiptApplyServiceImpl.java:1087)
 at com.sinosure.sol.service.edi.Common.domestic.EdiDomReceiptApplyServiceImpl.doReceipt(EdiDomReceiptApplyServiceImpl.java:984)
 at com.sinosure.sol.service.edi.Common.domestic.EdiDomReceiptApplyServiceImpl.doDrivenProcess(EdiDomReceiptApplyServiceImpl.java:283)
 at com.sinosure.sol.service.edi.Common.domestic.EdiDomReceiptApplyServiceImpl.doAutoCommit(EdiDomReceiptApplyServiceImpl.java:257)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
 at $Proxy67.doAutoCommit(Unknown Source)
 at com.sinosure.sol.service.edi.Common.EdiTimer.doEdiDomReceiptApply(EdiTimer.java:312)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:248)
 at org.springframework.scheduling.support.MethodInvokingRunnable.run(MethodInvokingRunnable.java:67)
 at org.springframework.scheduling.timer.DelegatingTimerTask.run(DelegatingTimerTask.java:53)
 at java.util.TimerThread.mainLoop(Timer.java:512)
 at java.util.TimerThread.run(Timer.java:462)
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
 at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
 at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
 at org.hi
<br>

 

 

以上错误 网上很多都说是因为更新视图时候的报错 ~!可是我的程序里并没有更新视图操作!所以很是费解 困扰了1天的时间

最后发现 竟然是因为往视图实体中 set了某个字段导致的 !  后来发现是 只要set了与原视图不一样的值 就会报错! 它会认为对视图有了修改!

 很是蹊跷...特此记录!

 

转 :

我在视图的处理中就遇到了类似的问题,我想在Service层,对一些空值做一些特殊的处理,结果hibernate自作聪明的帮我同步到数据库,当然视图的update在hibernate中默认情况下是不被允许的,就会抛出异常。我不想在Action中进行这种处理,但在Service层中数据又极有可能同步到数据库。幸好,hibernate还有一个比较好玩的功能叫做更新不同步的配置,这下让我喜出望外了。在hibernate映射文件中,找到需要特殊处理的属性,将其update属性设置为false。具体示例如下:

<property name="applyMoney"          type="java.math.BigDecimal" insert="false" update="false">                   <column name="APPLY_MONEY" precision="22" scale="0" />   </property>