spring+ ibatis 插入clob blob時
在網上找了幾個例子,有點好用,有的報錯
報錯如下:
1.Spring transaction synchronization needs to be active for setting values in iBATIS TypeHandlers that delegate to a Spring LobHandler
2. Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
大體就這兩個
總的說來,就是因為事務的配置問題.
如果,你的添加或更新操作不在add*和edit*的范圍內,而你又采用了倒霉的14行配置的時候,你的麻煩就來了......
解決方法有很多,刪掉啊,換成PROPAGETION_REQUIRED啊都可以....推薦第二種吧....
你的服務類如此配置....
額....不管你惡心沒惡心,反正我是惡心了.
在網上找了幾個例子,有點好用,有的報錯
報錯如下:
1.Spring transaction synchronization needs to be active for setting values in iBATIS TypeHandlers that delegate to a Spring LobHandler
2. Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
大體就這兩個
總的說來,就是因為事務的配置問題.
1
<!-- 事務管理 -->
2
<bean id="transactionManager2" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
3
<property name="dataSource" ref="dataSource"></property>
4
</bean>
5
6
<!-- 聲明式事務管理 -->
7
<bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
8
abstract="true">
9
<property name="transactionManager" ref="transactionManager2"></property>
10
<property name="transactionAttributes">
11
<props>
12
<prop key="add*">PROPAGATION_REQUIRED</prop>
13
<prop key="edit*">PROPAGATION_REQUIRED</prop>
14
<prop key="*">readOnly</prop>
15
</props>
16
</property>
17
</bean>
18
19
<bean id="sqlMapClient2"
20
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
21
<property name="dataSource">
22
<ref local="dataSource"/>
23
</property>
24
<property name="configLocation">
25
<value>classpath:SqlMapConfig.xml</value>
26
</property>
27
</bean>
注意:第14行
2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

如果,你的添加或更新操作不在add*和edit*的范圍內,而你又采用了倒霉的14行配置的時候,你的麻煩就來了......
解決方法有很多,刪掉啊,換成PROPAGETION_REQUIRED啊都可以....推薦第二種吧....
1
<bean id="foodService" parent="baseTransactionProxy">
2
<property name="target">
3
<bean class="com.bigcblob.impl.FoodServiceImpl">
4
<property ref="foodDao" name="foodDAO"/>
5
</bean>
6
</property>
7
</bean>

2

3

4

5

6

7

你的服務類如此配置....
額....不管你惡心沒惡心,反正我是惡心了.