Can .hbm files be used in a JPA application with Hibernate as JPA provider?
I'd like to replace custom BPM implementation with Activiti or jBPM-5 in a product which uses Hibernate (No JPA) with Spring for persistent layer implementation. Unfortunately, both Activiti and jBPM5 require JPA(according to their documentation) and it is not possible to migrate all existing Hibernate implementation to JPA in the product.
- Is there a way to configure JPA 2.0(JPA provider is Hibernate) with Spring 3 without migrating Hibernate implementation to JPA (i.e. retain .hbm files) ?
Note: I'm aware that application will not be compliant with JPA and another JPA provider can not be used.
- If there is way, assume Spring JTA trans开发者_如何学JAVAaction manager is configured with proper settings. can application logic and BPM workflow logic be executed in a single Spring transaction?
Regarding transactions see Activiti Spring Transaction Docs. If you cannot port your application to use JPA, another option is to layer a facade over your Hibernate domain. Activiti allows you to invoke methods on spring managed beans, so you could create a facade or utilize an existing service layer. Take a look at the sample applications that ship with Activity to see how the spring integration works.
jBPM w/JPA can be integrated with older non-JPA applications using Spring. The interactions with jBPM use JPA, but your application would use hibernate. The only drawback is that you have to deal with 2 different transactions, but any problems can mostly be mitigated.
Start your Hibernate transaction first and perform any business logic you want
Start your JBPM transaction by calling the JBPM APIs to start a process, or send an event, etc.
Any WorkItemHandler implementations need to join the outer transaction by using the session factory APIs
Hibernate flush() needs to be called at the end of each WorkItemHandler execution in order to trigger most exceptions generated by business code
The WorkItemHandler should catch any exception generated by the business code and rethrow it so that the JBPM transaction also fails
精彩评论