- 浏览: 1381054 次
- 性别:
- 来自: 江西
文章分类
- 全部博客 (287)
- oracle (30)
- Java (73)
- MySQL (16)
- Myeclipse/eclipse (12)
- javascript (15)
- JSP/Servlet (7)
- maven (14)
- AJAX (2)
- JQuery (9)
- tomcat (8)
- spring (21)
- Linux (28)
- PHP (9)
- UI (1)
- 编程错误及处理 (38)
- 多线程 (18)
- hibernate (10)
- Web Service (3)
- struts2 (6)
- log4j (3)
- SVN (4)
- DWR (1)
- lucene (1)
- 正则表达式 (4)
- jstl (2)
- SSL (3)
- POI (1)
- 网络编程 (1)
- 算法 (2)
- xml (4)
- 加密解密 (1)
- IO (7)
- jetty (2)
- 存储过程 (1)
- SQL Server (1)
- MongoDB (1)
- mybatis (1)
- ETL (1)
- Zookeeper (1)
- Hadoop (5)
- Redis (1)
- spring cloud (1)
最新评论
-
ron.luo:
牛逼,正解!
maven设定项目编码 -
lichaoqun:
java.sql.SQLException: Can't call commit when autocommit=true -
Xujian0000abcd:
Thanks...
Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the clas -
renyuan2ni:
[i][b][u]引用[list]
[*][img][flas ...
Manual close is not allowed over a Spring managed SqlSession -
851228082:
宋建勇 写道851228082 写道<!-- 文件拷贝时 ...
maven设定项目编码
org.hibernate.TransactionException: nested transactions not supported
- 博客分类:
- 编程错误及处理
使用hibernate4.3.5和spring4.0.3进行数据批量保存时出错,错误信息如下:
2014-07-25 13:44:38 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-1]-[com.wasu.monitor.service.NewdcErrordataService.save(NewdcErrordataService.java:129)]-[ERROR] nested transactions not supported
org.hibernate.TransactionException: nested transactions not supported
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:154)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1435)
at com.wasu.monitor.db.HibernateTemplate.batchSave(HibernateTemplate.java:122)
at com.wasu.monitor.service.NewdcErrordataService.save(NewdcErrordataService.java:121)
at com.wasu.monitor.service.NewdcErrordataService$$FastClassBySpringCGLIB$$ede15180.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:711)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
at com.wasu.monitor.service.NewdcErrordataService$$EnhancerBySpringCGLIB$$ac233e9a.save(<generated>)
at com.wasu.monitor.quartz.SpringQuartz.newdc_errordata_save(SpringQuartz.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:269)
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:321)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:111)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
提示好像是说存在事物嵌套,就是说事物至少开启了2次,于是我修改代码(即去掉事物控制代码部分)
修改前:
修改后:
修改后再次测试,数据成功插入!看来还真是事物嵌套造成!呵呵!
2014-07-25 13:44:38 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-1]-[com.wasu.monitor.service.NewdcErrordataService.save(NewdcErrordataService.java:129)]-[ERROR] nested transactions not supported
org.hibernate.TransactionException: nested transactions not supported
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:154)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1435)
at com.wasu.monitor.db.HibernateTemplate.batchSave(HibernateTemplate.java:122)
at com.wasu.monitor.service.NewdcErrordataService.save(NewdcErrordataService.java:121)
at com.wasu.monitor.service.NewdcErrordataService$$FastClassBySpringCGLIB$$ede15180.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:711)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
at com.wasu.monitor.service.NewdcErrordataService$$EnhancerBySpringCGLIB$$ac233e9a.save(<generated>)
at com.wasu.monitor.quartz.SpringQuartz.newdc_errordata_save(SpringQuartz.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:269)
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:321)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:111)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
提示好像是说存在事物嵌套,就是说事物至少开启了2次,于是我修改代码(即去掉事物控制代码部分)
修改前:
@Override public int batchSave(List<T> ts) { Session session = sessionFactory.getCurrentSession(); Transaction tx = session.beginTransaction(); for (int i = 0; i < ts.size(); i++) { Object obj = ts.get(i); session.save(obj); if (i % 20 == 0) { session.flush(); session.clear(); } } session.flush(); session.clear(); tx.commit(); log.info("保存了" + ts.size() + "记录"); return ts.size(); }
修改后:
@Override public int batchSave(List<T> ts) { Session session = sessionFactory.getCurrentSession(); for (int i = 0; i < ts.size(); i++) { Object obj = ts.get(i); session.save(obj); if (i % 20 == 0) { session.flush(); session.clear(); } } session.flush(); session.clear(); log.info("保存了" + ts.size() + "记录"); return ts.size(); }
修改后再次测试,数据成功插入!看来还真是事物嵌套造成!呵呵!
发表评论
-
ORA-12505, TNS:listener does not currently know of SID given in connect descript
2017-05-11 18:10 1367数据对接时需要连接对方的Oracle数据库,但程序在运行时出错 ... -
Failed to introspect annotations: interface com.xxx
2016-07-16 17:22 3874在使用maven打包发布项目时发现在tomcat容器中正常启动 ... -
MYSQL server has gone away
2016-07-08 20:08 650在使用命令source导入SQL数据时报错如下: 造成此问 ... -
java.io.NotSerializableException: java.util.ArrayList$SubList
2016-03-15 11:36 2867错误信息: 原代码: if (null != dto ... -
java.lang.IllegalStateException: Form too large586563>200000
2015-12-16 19:49 2053错误信息: java.lang.IllegalStateExc ... -
java.lang.IllegalStateException: Form too large586563>200000
2015-12-16 19:49 24错误信息: java.lang.IllegalStateExc ... -
The function size must be used with a prefix when a default namespace is not
2015-07-30 21:39 4233错误信息: 20:23:34.035 %PARSER_ERRO ... -
java.lang.NoSuchMethodError: org.springframework.expression.spel.SpelParserConfi
2015-07-30 09:41 9988错误信息: [WARNING] FAILED remoting ... -
getOutputStream() has already been called for this response
2015-07-24 09:55 2541错误信息: SEVERE: Servlet.service() ... -
spring aop未执行问题记录
2015-07-03 11:54 1438在类com.ipharmacare.plat.service. ... -
struts2传递参数时造成的404问题记录
2015-06-29 20:44 1052今天使用form表单提交数据时提示404错误,但当我直接在浏览 ... -
quorum.QuorumCnxManager: Cannot open channel to 2 at election address
2015-04-02 15:38 8354在进行hbase分布式安装时出现了如下信息: quorum.Q ... -
could only be replicated to 0 nodes, instead of 1
2015-03-28 17:51 2616用三台Linux搭建hadoop环 ... -
Does not contain a valid host:port authority: file:///
2015-03-08 15:15 1706Does not contain a valid host:p ... -
java.sql.SQLException: Can't call commit when autocommit=true
2015-01-30 11:22 4505错误信息: 一月 30, 2015 11:10:16 上午 o ... -
Shutting down 'proxoolDataSource' pool immediately [Shutdown Hook]
2014-07-19 23:03 1897错误信息如下: 原因是ProxoolDataSource的m ... -
org.apache.ibatis.binding.BindingException: Parameter 'ids' not found. Available
2014-06-13 16:01 1985MyBatis批量操作报错:Parameter 'xxxLis ... -
Manual close is not allowed over a Spring managed SqlSession
2014-05-28 21:34 26675整合spring与MyBatis时出现如下警告: [org.s ... -
log4j无日志输出
2014-05-21 15:31 1439今天在运行测试项目时发现没有日志输出(控制台和文件中都没日志输 ... -
class org.springframework.scheduling.quartz.CronTriggerBean
2014-05-09 08:56 2901提示错误信息:java.lang.IncompatibleCl ...
相关推荐
org.hibernate.TransactionException: JDBC rollback failed
3. 原理:Hibernate底层依赖于JDBC来与数据库进行交云,但它隐藏了JDBC API的复杂性。Hibernate通过使用Session和Transaction对象来管理与数据库的交互,它还提供了一个查询语言HQL用于对象查询。Hibernate的原理还...
错误九:Exception in thread "main" org.hibernate.TransactionException: nested transactions not supported 错误原因:Hibernate不支持嵌套事务,即在一个事务中开启另一个事务。这通常是由于在已经处于事务...
nested exception is org.hibernate.TransactionException: JDBC rollback failed 这表明Hibernate事务回滚操作失败,导致事务不能正确回滚。 二、问题原因 该问题的主要原因是手动对数据库做了些操作,导致...
错误表现:事务提交时出现“org.hibernate.TransactionException: Transaction was marked for rollback only; cannot commit”异常。 解决方案:检查事务的回滚规则,确保在try-catch块中正确处理事务。对于Spring...
【分布式事务与TransactionScope详解】 分布式事务是在多台计算机或多个数据库系统间协调进行的一组操作,目的是确保跨多个资源的数据一致性。TransactionScope是.NET框架2.0引入的一个类,用于简化分布式事务的...
│ hibernate.cfg.xml │ HibernateDaoImpl.java │ HibernateSessionFactory.java │ HibernateUtil.java │ JsonUtil.java │ list.txt │ log4j.properties │ messageResource_zh_CN.properties │ spring.xml ...
HibernateInterceptor HibernateJdbcException HibernateJdbcException HibernateJpaDialect HibernateJpaVendorAdapter HibernateObjectRetrievalFailureException HibernateObjectRetrievalFailureException...
### Hibernate 3.2 官方用户手册知识点详解 #### 一、概述 Hibernate 是一款开源的对象关系映射 (ORM) 工具,用于 Java 应用程序与数据库交互。它能够将 Java 对象自动持久化到关系型数据库中,从而简化了数据访问...
- **PROPAGATION_NOT_SUPPORTED**:以非事务的方式执行操作,如果当前存在事务,则挂起当前的事务。 - **PROPAGATION_NEVER**:以非事务方式执行,如果当前存在事务,则抛出异常。 - **PROPAGATION_NESTED**:如果...
默认情况下,如果方法抛出未检查异常(继承自RuntimeException的异常)或者TransactionException,Spring会回滚事务;否则,事务会在方法结束时提交。 ```java @Service public class UserService { @...
为确保事务正确回滚,可以显式地抛出`TransactionException`或者使用`@Transactional(rollbackFor = Exception.class)`。 3. **事务边界**:`@Transactional`只对被代理的方法有效。如果事务性方法内部调用了非事务...
TransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException; void commit(TransactionStatus status) throws TransactionException; void rollback(TransactionStatus ...
$result[0]) throw new TransactionException(PDO_ERROR_CODE, '更新用户失败', $result); }); echo_msg('注册成功'); //可以直接提交json,用下面方式接收 $newUser = request_object(); //$newUser = ...
public void handleException(TransactionException ex) { // 处理异常并回滚事务 } @After("execution(* com.example.service.TransactionService.*(..))") public void commitTransaction() { // 提交事务 ...
protected void onRun() throws TransactionException { // 在这里执行数据库操作 User user = new User().name("Jane").email("jane@example.com"); user.save(); } @Override protected void onFinish...
3. **TransactionException.java** - 这个文件可能定义了一个自定义的异常类,用于在交易过程中捕获和处理错误或异常情况。 4. **i3package-info.java** - 这个文件通常用于提供包级别的注释,可能包含了关于这个包...