随笔分类 -  ssh

摘要:在工程中导入spring支持,导入jar包在spring配置文件中配置dataSource和SessionFactory,将hibernate配置与Spring配置整合在一起(可以删除hibernate.cfg.xml文件);导入数据库源所要使用的Jar包修改所有DAO的hibernate实现,因为Spring中提供了一个HibernateDAOSupport类,可以简化数据库的操作。使用所有DAO类都继承自该类将DAO采用依赖注入的方式注入到Biz中,再将Biz采用依赖注入的方式注入到Action中,在Spring配置文件中做相应配置在web.xml文件中配置监听器以及web应用的初始化参数 阅读全文
posted @ 2013-06-21 20:39 ㊣执着㊣ 阅读(193) 评论(0) 推荐(0)
摘要:原理:1.通过Configuration().configure();读取并解析hibernate.cfg.xml配置文件2.由hibernate.cfg.xml中的<mapping resource="com/xx/User.hbm.xml"/>读取并解析映射信息3.通过config.buildSessionFactory();//创建SessionFactory4.sessionFactory.openSession();//打开Sesssion5.session.beginTransaction();//创建事务Transation6.persistent 阅读全文
posted @ 2013-05-04 21:53 ㊣执着㊣