Ordre juste
Most of the time we don’t care about the hibernate mapping configuration when we deploy an application based on JBPM (a worflow framework from Jboss). But if you want to use the same session factory for JBPM and your custom objects (the JBPM spring module have some helper classes) you have several options for the sessionFactory bean declaration in the spring configuration file :
- use two mapping sections : one for the JBPM jar file and one for the directory where the mapping files of custom objects are :
<bean id=“sessionFactory”…>
<property name=“mappingDirectoryLocations”> <list> <value>classpath*:**/your/custom/objects/mapping</value> </list> </property> <property name=“mappingJarLocations”> <list> <value>file:**/jbpm-jpdl.jar</value> </list> </property> </bean>
-
or extract the JBPM mapping files (find all .hbm.xml files in the extracted JAR) and add the directory to the mappingDirectoryLocations :
<property name=“mappingDirectoryLocations”> <list> <value>classpath*:**/your/custom/objects/mapping</value> <value>classpath:/the/directory/JBPM/mapping/files/</value> </list> </property>
but the order of the mapping files is important : JBPM has a custom type (string_max) declared in the hibernate.queries.hbm.xml file, this file should be before any other JBPM mapping file. I not you encounter this exception when the session factory is build :
Caused by: org.hibernate.MappingException: Could not determine type for: string_max, for columns: [org.hibernate.mapping.Column(MESSAGE_)]
or
Caused by: org.hibernate.MappingException: Could not determine type for: string_max, for columns: [org.hibernate.mapping.Column(DESCRIPTION_)] …
And if you use the 3.2 version of JBPM with the spring module (for 3.1) one minor modification is needed from the manual :
- The transactionnal service in the jbpm.cfg.xml : is mandatory
Billet publié dans les rubriques Programmation le