6

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.

  1. 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.

  1. If there is way, assume Spring JTA transaction manager is configured with proper settings. can application logic and BPM workflow logic be executed in a single Spring transaction?
Sujee
  • 4,985
  • 6
  • 31
  • 37
  • This doesn't exactly answer your question, but I recently had a similar situation, and ended up using HibernateTools to convert my *.hbm.xml files to JPA annotated beans. It was fairly painless and saved me the effort of going through what you're doing now. Is this an option for you? – Fil Feb 10 '11 at 22:46
  • Thank you @Filip Zalewski. The product is big in terms of its size. Only reason, I'd to change to JPA is to run BPM and application in the same transaction. I don't think, Migration is the right choice. – Sujee Feb 11 '11 at 02:43
  • Seems to be possible: http://bill.burkecentral.com/2007/07/06/co-existence-with-hibernate-jpa-and-ejb3/ http://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html/configuration.html – David Victor Feb 11 '11 at 10:20

2 Answers2

1

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.

Rich Kroll
  • 3,995
  • 3
  • 23
  • 28
0

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.

enter image description here

  1. Start your Hibernate transaction first and perform any business logic you want

  2. Start your JBPM transaction by calling the JBPM APIs to start a process, or send an event, etc.

  3. Any WorkItemHandler implementations need to join the outer transaction by using the session factory APIs

  4. Hibernate flush() needs to be called at the end of each WorkItemHandler execution in order to trigger most exceptions generated by business code

  5. The WorkItemHandler should catch any exception generated by the business code and rethrow it so that the JBPM transaction also fails

John Scattergood
  • 1,032
  • 8
  • 15