请原谅我的小白,我是个什么都会什么都不会的半桶水
public void register(User user) throws Exception {
getHibernateTemplate().save(user);
}
这个插入方法和
public void register(User user) throws Exception {
super.getSession().save(user);
}
有什么不同呢???
有人说super.getSession().save(user)是错的,应该直接session.save(user)????事务配置:
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean>
<bean id="transactionProxyFactory" abstract="true" lazy-init="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"> <ref local="transactionManager"/> </property> <property name="transactionAttributes"> <props> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="insert*">PROPAGATION_REQUIRED</prop> <prop key="del*">PROPAGATION_REQUIRED</prop> <prop key="add*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="search*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="remove*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="query*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="list*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="count*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean>
<bean id="userDao" class="org.lxh.myzngt.dao.impl.IUserDAOImpl"> <property name="hibernateTemplate" ref="hibernateTemplate"/> </bean>
那如果我用super.getSession().save(user)插入东西的话,该如何配置,求教了
public void register(User user) throws Exception {
getHibernateTemplate().save(user);
}
这个插入方法和
public void register(User user) throws Exception {
super.getSession().save(user);
}
有什么不同呢???
有人说super.getSession().save(user)是错的,应该直接session.save(user)????事务配置:
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean>
<bean id="transactionProxyFactory" abstract="true" lazy-init="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"> <ref local="transactionManager"/> </property> <property name="transactionAttributes"> <props> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="insert*">PROPAGATION_REQUIRED</prop> <prop key="del*">PROPAGATION_REQUIRED</prop> <prop key="add*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="search*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="remove*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="query*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="list*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="count*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean>
<bean id="userDao" class="org.lxh.myzngt.dao.impl.IUserDAOImpl"> <property name="hibernateTemplate" ref="hibernateTemplate"/> </bean>
那如果我用super.getSession().save(user)插入东西的话,该如何配置,求教了
总之会得到1个session对象。
super.getSession()你是怎么实现的呢?
我问的是如果用super.getSession()该怎么配置事物呢???