【正文】
s bean id=―date‖ class=―‖/ bean id=helloBean class= constructorarg index=0 valuehello/value /constructorarg constructorarg index=1 ref local=―date‖/ /constructorarg /bean /beans 構(gòu)造器注入 Spring與 Hibernate整合 通過數(shù)據(jù)源配置 SessionFactory HibernateTemplate與 HibernateDaoSupport 定義 DAO接口,實現(xiàn) DAO接口 編寫 bean定義文件定義 Datasource、SessionFactory、 DAO 客戶端調(diào)用 DAO SessionFactory與 DataSource S e s s i o n F a c t o r yd a t a S o u r c em a p p i n g R e s o u r c e sh i b e r n a t e P r o p e r t i e s: D a t a S o u r c e: L i s t: P r o p e r t i e sD r i v e r M a n a g e r D a t a S o u r c ed r i v e r C l a s s N a m eu r lu s e r n a m ep a s s w o r d: S t r i n g: S t r i n g: S t r i n g: S t r i n g通過數(shù)據(jù)源配置 SessionFactory bean id=dataSource class=. ― destroymethod=close property name=driverClassName value/value /property property name=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)。 this. date = date 。 private Date date = NoBody。 } } beans bean id=helloBean class= constructorarg index=0 valuehello/value /constructorarg constructorarg index=1 valuetom/value