2011-08-11 11:07:07.576::WARN: Nested in org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];
--- The error occurred in sqlmap/SITE_SqlMap.xml.
--- The error occurred while applying a parameter map.
--- Check the SITE.insert-InlineParameterMap.
--- Check the parameter mapping for the 'schedule' property.
--- Cause: java.lang.IllegalStateException: Spring transaction synchronization needs to be active for setting values in iBATIS TypeHandlers that delegate to a Spring LobHandler; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in sqlmap/SITE_SqlMap.xml.
--- The error occurred while applying a parameter map.
--- Check the SITE.insert-InlineParameterMap.
--- Check the parameter mapping for the 'schedule' property.
--- Cause: java.lang.IllegalStateException: Spring transaction synchronization needs to be active for setting values in iBATIS TypeHandlers that delegate to a Spring LobHandler:
java.lang.IllegalStateException: Spring transaction synchronization needs to be active for setting values in iBATIS TypeHandlers that delegate to a Spring LobHandler
at org.springframework.orm.ibatis.support.AbstractLobTypeHandler.setParameter(AbstractLobTypeHandler.java:95)
at com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap.setParameter(ParameterMap.java:173)
at com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap.setParameters(ParameterMap.java:133)
at com.ibatis.sqlmap.engine.execution.DefaultSqlExecutor.executeUpdate(DefaultSqlExecutor.java:75)
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteUpdate(MappedStatement.java:216)
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:94)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:404)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
at org.springframework.orm.ibatis.SqlMapClientTemplate$8.doInSqlMapClient(SqlMapClientTemplate.java:366)
用了spring3也有一段时间了,但是今天竟然在clob类型上折腾得要死要活的,主要是报了上面的一个异常,这个异常说的是操作clob时要在事务里面管理,否则不给你艹。
但是让我郁闷的是我已经在逻辑类头加了
@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
这样的事务管理,为什么还是不行呢?狗日的,最后没办法按照网上的一篇文章解决了这个问题,如下:
参考链接:http://blog.csdn.net/cwb1128/article/details/4342141
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="transactionManagerRootProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="proxyTargetClass">
<value>false</value>
</property>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="update*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="select*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
<bean id="nativeJdbcExtractor"
class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"
lazy-init="true" />
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler"
lazy-init="true">
<property name="nativeJdbcExtractor">
<ref local="nativeJdbcExtractor" />
</property>
</bean>
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="F:/39project/R/src/main/resources/SqlMapConfig.xml"/>
<property name="dataSource" ref="dataSource" />
<property name="lobHandler">
<ref local="oracleLobHandler" />
</property>
</bean>
<bean id="siteDao" class="net.health.adr.admin.dao.ibatis.SiteDaoImpl">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
<bean id="siteProxyDao" parent="transactionManagerRootProxy">
<property name="target">
<ref bean="siteDao" />
</property>
</bean>
SiteDao siteDao = (SiteDao) ctx.getBean("siteProxyDao");
总算可以插入,深深的插入进去了,艹
但是为什么不能用注解事务配置呢?还有待研究
分享到:
相关推荐
Spring事务同步示例 基于示例项目。
里面为一个演示spring事务传播机制的小demo。简单实现转账功能,通过添加注解调整传播级别,同时通过日志打印查看sql是否执行,在mysql中的数据是否发生了变化(操作提交还是回滚了)。
spring-transaction.jar.zip
之前一直找原因,最后知道了解决方法,具体请下载源码查看。特别是用到throw的事务中
Spring在Transaction事务传播行为种类,希望对大家有所帮助
org.springframework.transaction-3.2.2.RELEASE最新版本
NULL 博文链接:https://wsjjasper.iteye.com/blog/1570448
org.springframework.transaction-3.0.0.M4.jar
Implementing Transaction Suspension in Spring
Step By Step guide for Creating a Transaction in MII to call an RFC Module.pdf
org.springframework.transaction-3.1.0.M2
Spring中的事务管理问题:org.springframework.transaction-3.1.0.M1.jar包。org.springframework.transaction-3.1.0.M1.jar包。
spring 事务管理工程,导入到MyEclipse 中既可以使用
org.springframework.transaction-3.1.0.M1.jar
分布式事务框架LCN支持springcloud 2.0.5 ,transaction-springcloud-4.1.2.jar
org.springframework.transaction-3.2.4.RELEASE.jar,最新版的org.springframework.transaction,Wed Aug 07 16:44:37 GMT+01:00 2013
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionInterceptor#0': Error setting property values; nested ...
How to use Spring Persistence, including using persistence tools in Spring as well as choosing the best Java persistence frameworks outside of Spring How to work with Spring Framework features such as...
12. Spring Transaction Management 13. Spring Batch 14. Spring NoSQL and Big Data 15. Spring Java Enterprise Services and Remoting Technologies 16. Spring Messaging 17. Spring Integration 18. Spring ...
Spring is designed to be non-intrusive, meaning that your domain logic code generally has no dependencies on the framework itself. In your integration layer (such as the data access layer), some ...