使用spring的hibernateTemplate的方法
使用spring的hibernateTemplate的方法版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://huahuazhu.blogbus.com/logs/24775065.html
?
通过hibernateTemplate获取session/connection
第一种、Connection con?=?hibernateTemplate.getSessionFactory().getCurrentSession().connection();
第二种、
hibernateTemplate.execute(
?new?HibernateCallback()?{
??public?Object?doInHibernate(Session?session)?throws?SQLException{
???CallableStatement?cs?=?session.connection().prepareCall("{call?collin000.updateDepart}");????
???cs.executeUpdate();
???return?null;
?????}
?}
);
<beans>
?
?<bean id="dataSource" />
?????? </property>
??? </bean>
?? <bean id="userDAOProxy" />
???? </property>
???? <property name="target">
???????? <ref local="userDAO" />
???? </property>
???? <property name="transactionAttributes">
???????? <props>
??????????? <prop key="create*">PROPAGATION_REQUIRED</prop>
???????? </props>
???? </property>
?? </bean>
</beans>