我的是struts2+hibernate3+spring2+oracle 9,想实现的是将CLOB字段的类型入库,

但运行后出现如下错误信息:

Active Spring transaction synchronization or active JTA transaction with specified

我的结构是这样的:

 

首先是HBM文件:

     <property name="content" type="org.springframework.orm.hibernate3.support.ClobStringType">

            <column name="CONTENT"  />

        </property>

POJO里:

private  String content;

为了方便,我这样搞,把基本的增删改等归纳到一个类里去了;

public class CommonServiceImpl extends HibernateDaoSupport implements

  CommonService

{

 /**

  * 保存对象

  *

  * @param temp

  * @param item

  * @return

  */

 protected Serializable save(HibernateTemplate temp, Object item) {

  return temp.save(item);

 }

}

一个文章保存的实现类如下:

public class ArticleServiceImpl extends CommonServiceImpl implements IArticleService{

。。。。。一些其他逻辑方法

}

applicationContext.xml配置文件:

<bean id="lobHandler" lazy-init="true"   class="org.springframework.jdbc.support.lob.OracleLobHandler">

        <property name="nativeJdbcExtractor">

            <ref bean="nativeJdbcExtractor"/>

        </property>

</bean>

<bean id="nativeJdbcExtractor" lazy-init="true"  

class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor"/>

 

 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

 

  <property name="dataSource">

   <ref local="dataSource" />

  </property>

    <property name="lobHandler" ref="lobHandler"/>

.....

</bean>

 

<bean id="commonServiceImpl" class="com.trustel.service.CommonServiceImpl">

  <property name="sessionFactory">

   <ref local="sessionFactory" />

  </property>

 

 </bean>

 <bean id="commonService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">

  <property name="transactionManager">

   <ref bean="transactionManager" />

  </property>

  <property name="target">

   <ref local="commonServiceImpl" />

  </property>

  <property name="transactionAttributes">

   <props>

    <prop key="*">PROPAGATION_REQUIRED</prop>

   </props>

  </property>

 </bean>

 <bean id="txProxyTemplate" abstract="true"

class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">

     <property name="proxyTargetClass">

      <value>true</value>

     </property>

     <property name="transactionManager">

      <ref bean="transactionManager"/>

     </property>

     <property name="transactionAttributes">

   <props>

          <prop key="*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-Exception</prop>

      </props>

     </property>

 </bean>

对于文章类的服务层配置如下:

<bean id="articleService"

  class="com.djs.um.service.article.impl.ArticleServiceImpl">

  <property name="articleDao">

   <ref bean="articleDao" />

  </property>

 </bean>

</beans>

对于文章类的DAO层配置如下:

<bean id="articleDao" parent="txProxyTemplate">

     <property name="target">

       <bean class="com.djs.um.dao.impl.ArticleDaoImpl">

        <property name="sessionFactory">

    <ref bean="sessionFactory" />

   </property>

       </bean>

     </property>

   </bean>

在STRUTS2的ACTION类中,只需要在代码里注入articleService就可以了。

奇怪的是,我只是配了CLOB才出现这个问题,不用的话其他运行一切正常。