Could not obtain transaction-synchronized Session for current thread
2016-11-14 22:21
351 查看
(hibernate4)
已经在web.xml中已经使用
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>sessionFactory</param-value>
</init-param>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>flushMode</param-name>
<param-value>AUTO</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
但是任然报错,后来----->
在application.xml
<!-- 扫描业务逻辑层和模型层 -->
<context:component-scan base-package="com.dao"/>
<context:component-scan base-package="com.service"/>
<context:component-scan base-package="com.action"/>
<context:component-scan base-package="com.serviceImpl"/>
<context:component-scan base-package="com.daoImpl"/>
<!-- 支持注解 -->
<context:annotation-config/>
<tx:annotation-driven transaction-manager="transactionManager"/>
在serviceImpl中的方法上添加
@Transactional
public void addSubject(Subject subject) {
save(subject);
}
已经在web.xml中已经使用
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>sessionFactory</param-value>
</init-param>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>flushMode</param-name>
<param-value>AUTO</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
但是任然报错,后来----->
在application.xml
<!-- 扫描业务逻辑层和模型层 -->
<context:component-scan base-package="com.dao"/>
<context:component-scan base-package="com.service"/>
<context:component-scan base-package="com.action"/>
<context:component-scan base-package="com.serviceImpl"/>
<context:component-scan base-package="com.daoImpl"/>
<!-- 支持注解 -->
<context:annotation-config/>
<tx:annotation-driven transaction-manager="transactionManager"/>
在serviceImpl中的方法上添加
@Transactional
public void addSubject(Subject subject) {
save(subject);
}
相关文章推荐
- SpringMVC中Could not obtain transaction-synchronized Session for current thread的解决方案
- 关于Hibernate Could not obtain transaction-synchronized Session for current thread
- SpringMVC中Could not obtain transaction-synchronized Session for current thread的解决方案
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- 【Hibernate】Could not obtain transaction-synchronized Session for current thread
- 错误记录(九)Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- SSH整合时出现Could not obtain transaction-synchronized Session for current thread
- org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread 异常处理方式
- spring+hibernate Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- HibernateException: Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread 解决方案