与石英一起使用Hibernate会话 [英] Using Hibernate session with quartz
问题描述
我有一个使用框架的Web应用程序,如Struts和Hibernate。目前,我正在使用Quartz开发此应用程序的调度程序。在编码时,我意识到使用Quartz的线程不可能使用Hibernate会话。
任何人都可以使用石英job类的hibernate会话解决方案吗?
一种方法是使用 HibernateUtil
class ,它在静态初始化器中构建 SessionFactory
,并通过 public static
getter。你的Quartz作业可以创建 Session
作为 HibernateUtil.getSessionFactory()。getCurrentSession()
并使用它。
I've a web application which uses framework like Struts and Hibernate. Currently I'm developing a scheduler for this application using Quartz. While coding I realized that the use of Hibernate session is not possible with the threads of Quartz.
Anybody have a solution for using hibernate sessions from quartz job class?
One approach is to use a HibernateUtil
class which builds the SessionFactory
in a static initializer and makes it available via a public static
getter. Your Quartz job can create a Session
as HibernateUtil.getSessionFactory().getCurrentSession()
and use it.
这篇关于与石英一起使用Hibernate会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!