日期:2014-05-20 浏览次数:20759 次
<bean id="proxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <property name="transactionManager" ref="hibernateTransactionManager"/> <property name="transactionAttributes"> <props> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="delete*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <!-- 用户管理代理 --> <bean id="userManageProxy" parent="proxy"> <property name="target" ref="userManage"></property> </bean>
private static String USERTREEHQL = "from User u left join fetch u.userTrees ut left join fetch ut.tree where u.userName=? and u.passWord=?"; @SuppressWarnings("unchecked") public User getUserTree(String userName , String passWord) { List<User> users = getHibernateGeneralDao().find(USERTREEHQL, new Object[]{userName,passWord}); new HashSet(users); return users.isEmpty()?null:users.get(0) ; }
Session session = sessionFactory.openSession(); session.beginTransaction();