Announcement Announcement Module
No announcement yet.
Spring DM Server 2.0 and JPA Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring DM Server 2.0 and JPA

    We have selected JPA with HIbernate provider along with Hibernate Search as persistence solution for our spring dm server 2.0 based application.

    We have only one DB but entity classes for the tables will be distributes across different bundles. We have Bundle A with datasource and entityManagerFactory defined along with 25 Entity classes. Can entityManagerFactory in Bundle A be exported and used in other bundles that have their own entity classes ? say for example Bundle B that has 10 Entity classes of its own ?

    Can a single transaction involve entity classes from multiple bundles ?

  • #2
    Hibernate requires you to have all of the enitites registered with the entity manager, so i would lean towards saying no. You could have an entity manager per bundle with shared data source - this is normally how that would be done with hibernate (not OSGi). With this configuration though, you would need an XA datasource to share a transaction across EM's or a smart connection pool that shares a single connection amongst EM's (I don't know of anything that does this).

    With the heavy-weight of XA, if you need a single transaction, you should load all the enitites into a single entity manager which requires them to all be listed in a single persistence.xml (as far as I know).

    If you look at the OSGi in Anger presentation/slides, they used dynamic packages in OSGi (going from memory so the terms may not be correct) to give the EM access to all of the entities. They don't memntion it, but I assume they had a single persistence.xml that listed everything.

    Hope this helps since it is not exactly what you were asking.