1、Hibernate+Spring整合应用(小案例)1、导包 Hibernate Spring2、创建数据create table customer( c_id number(10) not null primary key, c_name varchar2(20)3、新建接口类import java.util.List;/* * 接口 * author ws*/public interface CustomerDao public List findall();4、实现接口 及测试main/* * 实现接口 * author ws*/public class CustomerImpl exte
2、nds HibernateDaoSupport implements CustomerDaopublic List findall() return this.getHibernateTemplate().find(from Customer);public static void main(String args) ApplicationContext context = new ClassPathXmlApplicationContext(applicationContext.xml);CustomerDao dao = (CustomerDao)context.getBean(custo
3、merImpl);List list = dao.findall();System.out.println(list.size();5、实体类public class Customer implements java.io.Serializable private Long CId;private String CName;get set .略6、Customer.hbm.xml 7、applicationContext.xml org.hibernate.dialect.Oracle9Dialect true com/xcx/entity/Customer.hbm.xml !- 此文件为Hibernate xml文件 在二者整合下可删除 -