hibernate4中session的update方法不受spring管理
本帖最后由 oiwuliang 于 2014-04-02 11:04:20 编辑
Session session = this.getSessionFactory().getCurrentSession();
session.save(entity);可以执行
session.update(entity)方法怎么不执行,什么情况,求大神指点,以下是spring配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"
default-autowire="byName">
<!-- 打开注解支持 -->
<context:annotation-config ></context:annotation-config>
<!-- 启动对@Aspects注解的支持 -->
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<!-- i18n Resource文件bundles -->
<bean scope="singleton" id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>i18n/messages</value>
<value>i18n/errors</value>
</list>
</property>
</bean>
<bean scope="singleton" id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath*:conf/jdbc.properties</value>
<value>classpath*:conf/hibernate.properties</value>
</list>
</property>
</bean>
<!-- 配置数据源 -->
<bean scope="singleton" id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<!-- 连接池启动时的初始值 -->
<property name="initialSize" value="1" />
<!-- 连接池的最大连接数 -->
<property name="maxActive" value="500" />
<!-- 最大空闲时,当经过一个高峰时间后,连接池可以慢慢释放一些连接,一直减少到maxIdle为止 -->
<property&n