hibernate保存数据报错

问题描述

org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; SQL [insert into ORC_T_BUSINESS_TRACK (BUSI_NUM, BUSI_TYPE, CREATE_DATE, CREATE_USER_NAME, CREATE_USER_NUM, REMARK, ID) values (?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch updateat org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:643)at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:104)at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:516)at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:394)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)at com.bsteel.shdc.service.OrcTBusinessTrackServiceImpl$$EnhancerByCGLIB$$416c9ca9.saveOrcTBusinessTrack(<generated>)at com.bsteel.shdc.bankservice.finance.redeem.controller.AuditController.signaTure1(AuditController.java:642)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221)at com.bsteel.shdc.manager.permission.filter.AuthFilter.doFilter(AuthFilter.java:101)at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)at org.mortbay.jetty.Server.handle(Server.java:326)at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch updateat org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:262)at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:178)at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:76)at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:512)... 47 moreCaused by: java.sql.BatchUpdateException: ORA-01401: inserted value too large for columnat oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:345)at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10844)at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)... 56 more[color=red][/color] 问题补充:以上是报错信息 Map<String,String> user=new HashMap<String,String>(); user.put(LSConstants.USER_LOGIN_NO, (String) getUseInfo().get(LSConstants.USER_LOGIN_NO));user.put(LSConstants.USER_LOGIN_NAME, (String) getUseInfo().get(LSConstants.USER_LOGIN_NAME));orcTBusinessTrackService.saveOrcTBusinessTrack(redeemCode, "ARGUEREDEEM_COUNT", "赎单已完成", user);这是我调用的方法

解决方案

1.插入的数据中,有的字段为null,但是数据库表限制该字段不能为null Could not execute JDBC batch update; SQL [insert into ORC_T_BUSINESS_TRACK (BUSI_NUM, BUSI_TYPE, CREATE_DATE, CREATE_USER_NAME, CREATE_USER_NUM, REMARK, ID) values (?, ?, ?, ?, ?, ?, ?)]; constraint [null];2.批量更新数据时,有些数据的字段值超过了数据库表定义的字段最大值,要么扩大该字段的值,要么对插入的数据进行校验Caused by: java.sql.BatchUpdateException: ORA-01401: inserted value too large for column
解决方案二:
其实吧,出现异常,定位的话只要看Caused by后面的就行了。。Caused by: java.sql.BatchUpdateException: ORA-01401: inserted value too large for column 有个字段的值太大了。。就这么简单。。目测是某个字符串长度没给够,自己检查下数据库表和hibernate配置文件吧
解决方案三:
Could not execute JDBC batch update; SQL [insert into ORC_T_BUSINESS_TRACK (BUSI_NUM, BUSI_TYPE, CREATE_DATE, CREATE_USER_NAME, CREATE_USER_NUM, REMARK, ID) values (?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException没有代码 只能从你上面报出的异常来 推测 1.可能你数据库里面的字段设置不能为空 但是你往做句库做动作的时候 这个字段上的值是空的2.可能是配置文件设置了关联,数据却没有关联造成的,只要数据正确就没有问题。另外,造成这个原因的还可能是数据库的驱动jar包不支持。3.因为Hibernate Tools(或者Eclipse本身的Database Explorer)生成*.hbn.xml工具中包含有catalog="***"(*表示数据库名称)这样的属性,将该属性删除就可以了4.估计是你的列名里面有关键字的原因吧,命名列的时候不要单独使用date,ID...这种关键字

时间: 2024-09-21 07:12:03

hibernate保存数据报错的相关文章

Hibernate读取数据报错

问题描述 下列代码按说是没问题的.为什么会报那么奇怪的错误public Unit getUnit(int id) {Session session=baseDao.getSession();Criteria criteria = session.createCriteria(Unit.class);criteria.add(Restrictions.eq("id", id));Unit unit = (Unit) criteria.list().get(0);Hibernate.ini

紧急求救,在线等,hibernate插入更新数据报错

问题描述 紧急求救,在线等,hibernate插入更新数据报错 各位好: hibernate报错麻烦各位看一下,在本地和测试环境都没有问题.提到生产上后,就一直报这个错 2016-05-07 12:16:08:WARN http-8888-3 org.hibernate.util.JDBCExceptionReporter - SQL Error: 1, SQLState: 23000 2016-05-07 12:16:08:ERROR http-8888-3 org.hibernate.uti

rror 1615 tate 000-jdbc定时批量插入数据报错

问题描述 jdbc定时批量插入数据报错 错误提示如下: Dec 19 2014 12:20:00 AM org.hibernate.util.JDBCExceptionReporter logExceptionsWARNING: SQL Error: 1615 SQLState: HY000Dec 19 2014 12:20:00 AM org.hibernate.util.JDBCExceptionReporter logExceptionsWARNING: SQL Error: 1615 S

SISS保存时报错,无法保存数据流对象

问题描述 SISS保存时报错,无法保存数据流对象 无法保存包. (Microsoft Visual Studio) 程序位置: 在 Microsoft.DataTransformationServices.Design.Serialization.DtrDesignerSerializer.SerializePackage(IDesignerSerializationManager manager Package package TextWriter textWriter) 在 Microsof

linux/weblogic 某一模块新建点击保存时报错500

问题描述 linux/weblogic 某一模块新建点击保存时报错500 在linux系统的weblogic上部署的应用包,但是有一个新建页面点击报错报错500,控制台显示错误如图所示,有遇到同样错误或是熟悉weblogic的么?急求 解决方案 http://zhidao.baidu.com/link?url=6GSnOoJ8bBKVyoutxSUtD3BimSwyhN_qpYuxW5kYZtqPqiCcyOIjyrwIHljiRGhlQZoXfhhRMbBqOcWwb8plYHPlXhf1qe

spring mvc-springmvc获取json数据报错

问题描述 springmvc获取json数据报错 springmvc不通过bean获取json传过来数据的值,怎样写springMVC的控制层? 解决方案 你说得是什么意思呢?如果请求参数从前台传入后台是通过你的代码Json. stringify转化的JSON格式的数据的话,那么在后台收到的这个参数的本质类型是String,你使用时就需要使用JSON转换工具转成Java的对象. 解决方案二: 通不通过bean是什么意思?你只要response 的是json 格式就可以 . 解决方案三: 不通过b

框架-JAVA问题:hibernate测试时报错,说一个什么什么东西的构造器找不到

问题描述 JAVA问题:hibernate测试时报错,说一个什么什么东西的构造器找不到 代码稍多,我分开贴1,模型domain,get/set方法都是一键生成的,截图略-------> 2,四个模型分别对应的xml-----> 3,配置文件-------> 4,抽取的工具类----------> 7,测试-------> 解决方案 提示很明显是构造函数错误,出现这个错误,你好好看看是不是你的数据库表和你的实体类包括配置文件里的字段不一致导致的. 解决方案二: 所有类中都生成下

springmvc+hibernate服务器上报错,本地没问题

问题描述 springmvc+hibernate服务器上报错,本地没问题 使用springmvc+hibernate在服务器上部署的时候,访问控制器,能够进入控制器打出日志.但是无法显示页面.同时报错. org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException

oracle-text里修改一个timestamp格式的时间,使他为空后保存报错,说格式不对

问题描述 text里修改一个timestamp格式的时间,使他为空后保存报错,说格式不对 严重: Servlet.service() for servlet [jsp] in context with path [/java23_news] threw exception [An exception occurred processing JSP page /SaveNews.jsp at line 35 32: news.setSummary(summary); 33: news.setAut