ITeye博客

用spring事务时hibernate无法抓取对象

hanfeng450 · 2008-03-30 15:21 · Markdown

spring 的配置文件

<tx:advice id="txAdvice" transaction-manager="transactionManager">
	<tx:attributes>
		<tx:method name="find*" read-only="true"
			rollback-for="my.duds.exception.DudsException" />
		<tx:method name="delete*" read-only="false"
			rollback-for="my.duds.exception.DudsException" />
		<tx:method name="update*" read-only="false"
			rollback-for="my.duds.exception.DudsException" />
		<tx:method name="save*" read-only="false" 
			rollback-for="my.duds.exception.DudsException"/>
	</tx:attributes>
</tx:advice>

<aop:config proxy-target-class="true">
	<aop:advisor
		pointcut="execution(* my.duds.services.impl..*.*(..))"
		advice-ref="txAdvice" />
</aop:config>


<!-- 注入SessionFactory -->
<bean id="daoImpl"
	class="my.duds.dao.impl.DaoImpl">
	<property name="sessionFactory">
		<ref bean="sessionFactory"></ref>
	</property>
</bean>

hibernate的配置文件 News.hbm.xml

当我在jsp页面用 news.newType.newTypeName时,就会抛出session已经关闭的异常, 继而无法获取到newTypeName. 请教一下高手这个是什么问题.有什么办法解决. 我目前只有用left join fetch newType 才能得到newType对象. 除此之外还有其他方法吗?

评论(1)

  1. #1 楼 · bingyunxl · 2008-03-30 16:56

    会话没有传递到视图层,可以通过对象拷贝或者使用spring自己的一个解决方式,之前的帖子中有,可以找找

评论功能维护中,当前仅展示历史评论。