i use a custom OpenSessionFilter
as what you see, i remove session.setFlushMode(FlushMode.NEVER);Code:public class OpenSessionFilter extends OpenSessionInViewFilter{ final static Logger logger = Logger.getLogger(OpenSessionFilter.class.getName()); protected Session getSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException { Session session = SessionFactoryUtils.getSession(sessionFactory, true); return session; } }
every thing works fine
but i see some project ,such as confluence,petclinc sample
they all use TransactionProxy to do custom transaction on daos like this
here is my question:Code:<bean id="groupDao" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"> <ref local="transactionManager"/> </property> <property name="target"> <ref local="confluenceGroupDaoTarget"/> </property> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean>
what's the different between there two ways
which is good,and would second way get a poor performace?
how to choose the apropos way?
in confluence, some dao seems use way 1 (auto-flush),some use way 2(tran proxy)
it really confuse me...


Reply With Quote