Spring+Hibernate延迟加载测试基类
来源:互联网 发布:wifi没有可切换的网络 编辑:程序博客网 时间:2024/05/21 15:48
- package cn.com.oneslife;
- import junit.framework.TestCase;
- import org.hibernate.Session;
- import org.hibernate.SessionFactory;
- import org.junit.AfterClass;
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.support.FileSystemXmlApplicationContext;
- import org.springframework.orm.hibernate3.SessionFactoryUtils;
- import org.springframework.orm.hibernate3.SessionHolder;
- import org.springframework.transaction.support.TransactionSynchronizationManager;
- public abstract class AbstractTest extends TestCase{
- private static SessionFactory sessionFactory ;
- private static ApplicationContext act;
- public void setUp() throws Exception {
- act = new ClassPathXmlApplicationContext("applicationContext.xml");
- sessionFactory = (SessionFactory) getBean("sessionFactory");
- Session s = sessionFactory.openSession();
- TransactionSynchronizationManager.bindResource(sessionFactory,
- new SessionHolder(s));
- }
- protected static Object getBean(String beanName) {
- return act.getBean(beanName);
- }
- public void tearDown() throws Exception {
- SessionHolder holder = (SessionHolder) TransactionSynchronizationManager
- .getResource(sessionFactory);
- Session s = holder.getSession();
- s.flush();
- TransactionSynchronizationManager.unbindResource(sessionFactory);
- SessionFactoryUtils.closeSession(holder.getSession());
- }
- }
- Spring+Hibernate延迟加载测试基类
- Spring+hibernate延迟加载
- hibernate+spring延迟加载问题
- hibernate +spring 使用延迟加载
- 在spring中hibernate的延迟加载
- spring+hibernate引起的延迟加载
- spring+hibernate避免延迟加载异常
- 在spring中hibernate的延迟加载
- Hibernate+spring数据延迟加载问题解决方案。
- spring对hibernate延迟加载的支持
- Spring 接管 Hibernate 配置 延迟加载
- Hibernate 延迟加载类属性
- Hibernate延迟加载以及利用Spring事务完美解决延迟加载问题
- 论Spring与Hibernate的延迟加载和Dao模式
- Spring 与 Hibernate 的延迟加载和 Dao 模式
- 号称Spring+Hibernate避免延迟加载异常的Filter
- hibernate 延迟加载(Lazy)问题spring下解决方法
- Spring 与 Hibernate 的延迟加载和 Dao 模式(转)
- 学习xpath的好去处
- emacs中color-theme的正确配置方法
- 打工不如当老板,注册公司费用和步骤
- 转:Windows Sockets 网络编程(三) —— WINDOWS SOCKETS 1.1 程序设计
- SSH开发基础-Struts相关jar包简介
- Spring+Hibernate延迟加载测试基类
- 用SQL实现取员工日工作量和月工作量
- 使用SSH Secure File Transfer给RHEL5传JSP网站,出现文件夹大小写问题
- 浅说C++的指针
- 转:深入 CSocket 编程之阻塞和非阻塞模式
- 关于SQL时间类型的模糊查询
- 自己写的一个杀system.dll和autorun的一个批处理
- 为什么会出现LNK2005"符号已定义"的链接错误?
- sql 优化查询