ssh之雇员管理系统(2)-hibernate测试
2013-05-13 17:04
483 查看
二、测试hibernate是否配置成功
View Code
View Code
package com.wang.ssh; import org.apache.bsf.util.event.adapters.java_awt_event_ActionAdapter; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.wang.domain.Employee; import com.wang.service.imp.EmployeeService; import com.wang.service.interfaces.EmployeeServiceInter; public class Test { public static void main(String[] args) { /** * 测试Spring配置是否成功 */ // ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml"); // TestServcie testServcie = (TestServcie)ac.getBean("testServcie"); // System.out.println(testServcie.getName()+"***"); /** * 测试hibernater是否配置成功 */ ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml"); SessionFactory sessionFactory= (SessionFactory) ac.getBean("sessionFactory"); Session session = sessionFactory.openSession(); Employee employee = new Employee("Tom", "123@qq.com", new java.util.Date(), 123.45f); Transaction transaction = session.beginTransaction(); session.save(employee); transaction.commit(); } }
相关文章推荐
- 雇员管理系统ssh之准备1
- Spring 雇员管理系统SSH 1
- Spring 雇员管理系统SSH 3
- ssh之雇员管理系统(6)-解决中文乱码问题
- 雇员管理系统-SSH版(三)
- Spring 雇员管理系统SSH 4
- Spring 雇员管理系统SSH 6
- 雇员管理系统-SSH版(九)
- Spring 雇员管理系统SSH 5
- ssh之雇员管理系统(5)-将struts+spring整合
- 雇员管理系统-SSH版(四)
- 雇员管理系统-SSH版(八)
- ssh之雇员管理系统(8)-增加其他功能
- 雇员管理系统-SSH版(五)
- 雇员管理系统-SSH版(六)
- 雇员管理系统-SSH版(十)
- 雇员管理系统-SSH版(七)
- ssh之雇员管理系统(1)-spring测试
- 雇员管理系统ssh之准备2