Hi,
I just spend a few houres to figure how to use Hibernate Annotaiton with jBPM.
Here is the "receipt" (can probably be improved):
1-- Create an implementation of the db persistence service:
---------------------------------------------------------------------
package com.btc.fwk.jbpm;
[Cut imports]
public class PersistenceService extends DbPersistenceServiceFactory {
private static final Log _log =
LogFactory.getLog(PersistenceService.class);
private Configuration _configuration;
public PersistenceService() {
super();
_log.info("Creating Persistence Service");
}
public synchronized Configuration getConfiguration() {
_log.info("Creating AnnotationConfiguration");
if (_configuration == null) {
String hibernateCfgXmlResource = null;
if (JbpmConfiguration.Configs
.hasObject("resource.hibernate.cfg.xml")) {
hibernateCfgXmlResource =
JbpmConfiguration.Configs
.getString("resource.hibernate.cfg.xml");
}
String hibernatePropertiesResource = null;
if
(JbpmConfiguration.Configs.hasObject("resource.hibernate.properties")) {
hibernatePropertiesResource =
JbpmConfiguration.Configs.getString("resource.hibernate.properties");
}
_configuration = new AnnotationConfiguration();
_log.info("XML configuration file = " +
hibernateCfgXmlResource);
_log.info("Resource file = " +
hibernatePropertiesResource);
_configuration.configure(hibernateCfgXmlResource);
if( hibernatePropertiesResource != null ) {
_log.debug("Setting Persistence hibernate
properties from " + hibernatePropertiesResource);
Properties properties = new Properties();
InputStream is = null;
try {
is =
PersistenceService.class.getClassLoader().getResourceAsStream(hibernatePropertiesResource);
properties.load(is);
} catch(Exception e) {
_log.error(e);
_log.debug("Hibernate properties " +
hibernatePropertiesResource + " not found");
} finally {
if( is != null )
try {
is.close();
} catch (IOException e) {
_log.error(e);
}
}
_configuration.setProperties(properties);
}
}
return _configuration;
}
}
2-- Declare the service
---------------------------
In jbpm.cfg.xml:
<jbpm-context>
<!--
-->
3-- Declare the annotated classes
-----------------------------------------
Declare the annotated classes into the hibernate.cfg.xml file.
Hope this help
Thibault Cuvillier
http://www.btcweb.com
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3931848#3931848
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3931848
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user