This content has been marked as final.
Show 4 replies
-
1. Re: Jbpm classes deployed inside a hibernate HAR
kukeltje Aug 15, 2006 3:04 PM (in response to ulfreich)I need to use jBPM, which means I must include jBPM's persistent classes into the same SessionFactory.
I'm not a hibernate expert, but why? You can pass a sessionfactory to jBPM, so your app and jbpm share it.
But it might be I missed something -
2. Re: Jbpm classes deployed inside a hibernate HAR
ulfreich Aug 16, 2006 5:31 PM (in response to ulfreich)Thanks for your reply!
So what you mean is, I must create the SessionFactory with my own persistent classes (without including jBPM's) and then simply pass that SessionFactory to jBPM as in JbpmContext.setSessionFactory(SessionFactory), and that's it?
In the manual the only thing that says about including the user classes is:The easiest way to integrate your persistent classes with the jBPM persistent classes is by creating one central hibernate.cfg.xml. You can take the jBPM src/config.files/hibernate.cfg.xml as a starting point and add references to your own hibernate mapping files in there.
Manually typing the classes sure could be the easiest way, but doesn't seem so practical at all given that, to create a SessionFactory manually, I can add the full jBPM jars to the configuration doing something like:Configuration configuration = new Configuration(); configuration.addJar(myMappingsJar); // File object configuration.addJar(jbpmJarFile); configuration.addJar(jbpmIdentityJarFile); SessionFactory hibSessionFactory = configuration.buildSessionFactory(); JbpmSessionFactory sessionFactory = new JbpmSessionFactory(configuration, hibSessionFactory);
I'm looking for a way to do this using jBoss' Hibernate Archive (HAR). Thanks! -
3. Re: Jbpm classes deployed inside a hibernate HAR
jurglic Aug 16, 2006 7:04 PM (in response to ulfreich)Actually, you don't need har. Any sar will do.
Basically, you need a sar with all the hbm.xml files of jbpm and following mbean:<mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.jca:service=HibernateFactory,name=HibernateFactory"> <depends>jboss.jca:service=RARDeployer</depends> <depends>jboss.jca:service=DataSourceBinding,name=HibernateDB2</depends> <attribute name="SessionFactoryName">java:/HibernateSessionFactory</attribute> <attribute name="DatasourceName">java:/HibernateDB2</attribute> <attribute name="Dialect">org.hibernate.dialect.DB2Dialect</attribute> <attribute name="ShowSqlEnabled">true</attribute> <attribute name="ScanForMappingsEnabled">true</attribute> </mbean>
The mbean above will initialize hibernate session factory and load all hbm.xml files in the enclosing sar. Those mapping files should be for jbpm persistent objects and for yours own as well.
That was first step. Second step is to configure jbpm to use configured hibernate session factory and to deploy it. You can do that with customizing jbpm.cfg.xml in your jbpm sar. More accurately, you must configure persistence service in the following manner:<service name="persistence"> <factory> <bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory"> <field name="sessionFactoryJndiName"> <string value="java:/HibernateSessionFactory" /> </field> </bean> </factory> </service>
And thats about it. -
4. Re: Jbpm classes deployed inside a hibernate HAR
kukeltje Aug 16, 2006 7:08 PM (in response to ulfreich)Hey, great tip jurglic. Maybe others new this as well, but I didn't. Would you care to make a wiki page for this?