Results 1 to 2 of 2

Thread: Spring DM Server 2.0 and JPA

  1. #1
    Join Date
    Apr 2009
    Posts
    15

    Default 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. #2
    Join Date
    Jul 2007
    Posts
    101

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •