Spring transaction synchronization needs to be active for setting values in iBAT


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");


总算可以插入,深深的插入进去了,艹

但是为什么不能用注解事务配置呢?还有待研究
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值