Hello. The SessionFactory would are referring to is part of Hibernate. You can read up
on the Hibernate site how to create a SessionFactory.
For example, you could put the hibernate.cfg.xml file at the root of your classpath.
Then to get a SessionFactory, you can use this line of code:
SessionFactory sf = new Configuration().configure().buildSessionFactory();
There is also another way to get a SessionFactory.
In your jbpm.cfg.xml, there should be this line
<service name="persistence"
| factory="org.jbpm.persistence.db.DbPersistenceServiceFactory"/>
If there isn't, add it in between <jbpm-context></jbpm-context>
Add jbpm.cfg.xml to the root of your classpath.
You could then create a class with the a static field. i.e.:
private static final JbpmConfiguration jbpmConfiguration;
you can use a static initalizer in this class to create the JbpmConfiguration
object.i.e.:
static {
| try {
| jbpmConfiguration = JbpmConfiguration.getInstance();
| } catch (Throwable ex) {
| throw new ExceptionInInitializerError(ex);
| }
| }
and write a static method to get this object.i.e.:
public static JbpmConfiguration getJbpmConfiguration() {
| return jbpmConfiguration;
| }
You could call this class something like JbpmUtil
You could use a listener to create an instance of this object when your application
starts.
From then on, when you need a SessionFactory, you can use these lines
of code:
JbpmConfiguration jbpmConfig = JbpmUtil.getJbpmConfiguration();
| JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
| SessionFactory sessionFactory = jbpmContext.getSessionFactory();
Hopefully this helps. This is the way it worked for me to integrate jbpm, hibernate and
my own application.
Hopefully some of the seniors can add to this.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4035848#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...