spring 配置 hibernate事务

本人的目的是想解决一个Dao更新(this.getHibernateTemplate().update(product);)的时候抛出的一个事务异常:Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

1、applicationContext.xml(配置文件):

<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">

<context:annotation-config/>

<!-- 配置 IOC容器 自动扫描的包 -->
<context:component-scan base-package="com.bj969.dao"/>

<!-- 导入资源文件 -->
<context:property-placeholder location="classpath:db.properties"/>

<!-- 配置C3P0数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="user" value="${jdbc.user}"/>
    <property name="password" value="${jdbc.password}"/>
    <property name="jdbcUrl" value="${jdbc.jdbcUrl}"/>
    <property name="driverClass" value="${jdbc.driverClass}"/>

    <property name="initialPoolSize" value="${jdbc.initPoolSize}"/>
    <property name="maxPoolSize" value="${jdbc.maxPoolSize}"/>
</bean>

<!-- 配置 具名参数 
<bean id="namedParameterJdbcTemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
    <constructor-arg ref="dataSource"></constructor-arg>
</bean>
-->
<!-- 配置 SessionFactory 的实例 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
    <!-- 配置数据源 -->
    <property name="dataSource" ref="dataSource"/>
    <!-- 配置 Hibernate 配置文件的位置及名称 -->
    <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
    <!-- 配置 Hibernate 映射文件的位置及名称 -->
    <property name="mappingLocations" value="classpath:com/bj969/hibernate/entities/*.hbm.xml"/>     
</bean>

<!-- 配置事务容器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 支持  @Transactional 标记 -->
<tx:annotation-driven transaction-manager="transactionManager"/>

2、Dao文件部分代码:

@Transactional
@Service
public class ProductDao extends HibernateDaoSupport {

@Resource(name="sessionFactory")
public void setMySessionFactory(SessionFactory sessionFactory){
    super.setSessionFactory(sessionFactory);
}   

public void save(Product product) {
    this.getHibernateTemplate().save(product);
}

public void delete(Product product) {
    this.delete(product);
}

@Transactional(readOnly=false)
public void update(Product product) {
    this.getHibernateTemplate().update(product);
}

问题: 一加上程序还未运行就提示错误。
图片说明

高手帮忙看看我的事务配置文件有没有问题,我采用的是全注解方式,但 <tx:annotation-driven 一加到配置文件里还未运行就有错误。

http://blog.csdn.net/zljjava/article/details/7535710

未引入spring相关的DTD文件

这样引入的应该是正确的吧?

<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">

    ![图片说明](https://img-ask.csdn.net/upload/201603/23/1458697843_113659.png)

你的hibernate用的版本是多少啊?我之前就是用的5以上的版本,搭建ssh框架的时候,就因为版本问题而换了两次hibernate的版本,后来使用的是
hibernate4.1.7 Final