spring与hibernate整合内容摘要:

me=url valuejdbc: /property property name=usernamevalueroot/value/property property name=passwordvaluepwd/value/property /bean bean id=sessionFactory― class=. property name=dataSource ref local=dataSource / /property property name=mappingResources list valuemodel//value /list /property property name=hibernateProperties props prop key=/prop prop key=true/prop /props /property /bean HibernateDaoSupport public class StudentDAO extends HibernateDaoSupport implements IStudentDAO { public void saveStudent(Student stu) { getHibernateTemplate().save(stu)。 } public void modifyStudent(Student stu) { getHibernateTemplate().update(stu)。 } public Student find(Integer id) { Student stu = (Student) getHibernateTemplate().get(, id)。 return stu。 } } pu bl i c v oi d s e t S e s s i on Fa c t ory ( S e s s i on Fa c t ory s e s s i on Fa c t ory ) { hi be r na t e Te m pl a t e = ne w H i be r na t e Te m pl a t e ( s e s s i on Fa c t ory )。 }S t u d e n t D A O++++s a v e S t u d e n t ( S t u d e n t s t u )f i n d S t u d e n t ( S t u d e n t s t u )m o d i f y S t u d e n t ( S t u d e n t s t u )f i n d S t u d e n t s ( ): v o i d: S t u d e n t: v o i d: L i s tH i b e r n a t e D a o S u p p o r t h i b e r n a t e T e m p l a t e : H i b e r n a t e T e m p l a t e+ s e t S e s s i o n F a c t o r y ( S e s s i o n F a c t o r y s e s s i o n F a c t o r y )S e s s i o n F a c t o r y d a t a s o u r c e : D a t a S o u r c eD r i v e r M a n a g e r D a t a S o u r c ebean id=StudentDAO class=― property name=sessionFactory ref local=sessionFactory / /property /bean 配置 SessionFactory bean id=dataSource class=. ― destroymethod=clo。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。