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

spring 的配置文件
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>


<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
<hibernate-mapping>
<class name="my.duds.vo.News" table="News" schema="dbo" catalog="Duds">
<id name="newsId" type="java.lang.Long">
<column name="newsID" precision="18" scale="0" />
<generator class="native" />
</id>
<many-to-one name="admin" class="my.duds.vo.Admin" fetch="select">
<column name="adminID" precision="18" scale="0" />
</many-to-one>
<many-to-one name="newsType" class="my.duds.vo.NewsType" fetch="select">
<column name="newsTypeID" precision="18" scale="0" />
</many-to-one>
<property name="newsTitle" type="java.lang.String">
<column name="newsTitle" length="1000" />
</property>
<property name="newsText" type="java.lang.String">
<column name="newsText" />
</property>
<property name="newsPublishDate" type="java.util.Date">
<column name="newsPublishDate" length="23" />
</property>
<property name="newsClickCount" type="java.lang.Integer">
<column name="newsClickCount" not-null="true" />
</property>
</class>
</hibernate-mapping>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值