1
私はHibernate、Spring、JSFを使用しています。opensessioninviewを開いてトランザクションをコミットします
LazyInitializationExceptionを防ぐために、私はmyDAOで
<bean name="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
<property name="sessionFactory" ref="sessionFactory"/>
<property name="singleSession" value="true"/>
</bean>
を使用しています、私は、メソッド定義された:
public Collection<T> findAll() {
Session session = getSessionFactory().getCurrentSession();
Transaction tx = session.beginTransaction();
return
session.createCriteria(persistentClass
).setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY
).list();
}
をし、私はこのようなメソッドを呼び出す:で
@Transactional(readOnly = false, propagation = Propagation.SUPPORTS)
public Collection<MyData> getMyData() {
return (Collection<MyData>) myDAO.findAll();
}
このケースではSpringトランザクションを使用しました。 findAllメソッドでTransaction tx = session.beginTransaction(); and tx.commit()?
にトランザクションを開始する必要がありますか?
私は、Oracle 10g