You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Krishnaprasad Subbarao <kr...@in.ibm.com> on 2013/03/18 14:55:05 UTC

Persistence units

Hello,

I am working on a large application which has around 50 entities and many 
relational tables. We wish to use OpenJPA 2.1 as a Persistence provider. 

I would like to know what criteria's should be considered while deciding 
the number of persistence units to be defined in an application. Following 
are my questions about persistence units

1) What are points to be considered to decide how many persistence units 
should be created in an application?

2) Is it recommended to have one persistence unit per logical module 
(Business module) in an application?

While exploring I found that multiple persistence units are created mostly 
if different entities are packaged in different WAR/JAR/EAR files. Is this 
the only criteria to have multiple units?

Regards,

Krishnaprasad (Kp)


Re: Persistence units

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

IMO the criteria are:
1) can it be different databases
2) is it developped by differents teams
3)  (a bit less relevant) does it make sense for the design

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/3/18 Krishnaprasad Subbarao <kr...@in.ibm.com>

> Hello,
>
> I am working on a large application which has around 50 entities and many
> relational tables. We wish to use OpenJPA 2.1 as a Persistence provider.
>
> I would like to know what criteria's should be considered while deciding
> the number of persistence units to be defined in an application. Following
> are my questions about persistence units
>
> 1) What are points to be considered to decide how many persistence units
> should be created in an application?
>
> 2) Is it recommended to have one persistence unit per logical module
> (Business module) in an application?
>
> While exploring I found that multiple persistence units are created mostly
> if different entities are packaged in different WAR/JAR/EAR files. Is this
> the only criteria to have multiple units?
>
> Regards,
>
> Krishnaprasad (Kp)
>
>

Re: Persistence units

Posted by Chris Wolf <cw...@gmail.com>.
I found this information about multiple units / multiple
persistence.xml - apparently you can have multiple persistence.xml:

http://stackoverflow.com/questions/2971316/combine-two-or-more-persistence-xmls-into-one-when-packaging-war-many-modu

http://javahowto.blogspot.com/2007/06/where-to-put-persistencexml-in-web-app.html

http://docs.jboss.org/hibernate/stable/entitymanager/reference/en/html/configuration.html#setup-configuration-packaging

On Mon, Mar 18, 2013 at 11:20 AM, Chris Wolf <cw...@gmail.com> wrote:
> Kp,
>
> At the risk of hijacking your thread - I would like to add some
> specificity to your question..i.e.
> let's say I want to create two separate JAR projects, each has their
> own set of entities and persistence unit and, in fact, separate
> persistence.xml.  Will this work in a webapp when both resulting jars
> are added to the WAR's WEB-INF/lib?  Or must you only have a single
> persistence.xml in a given webapp and must implement some merging
> process in the build script?
>
> Thanks,
>
>     -Chris
>
> On Mon, Mar 18, 2013 at 9:55 AM, Krishnaprasad Subbarao
> <kr...@in.ibm.com> wrote:
>> Hello,
>>
>> I am working on a large application which has around 50 entities and many
>> relational tables. We wish to use OpenJPA 2.1 as a Persistence provider.
>>
>> I would like to know what criteria's should be considered while deciding
>> the number of persistence units to be defined in an application. Following
>> are my questions about persistence units
>>
>> 1) What are points to be considered to decide how many persistence units
>> should be created in an application?
>>
>> 2) Is it recommended to have one persistence unit per logical module
>> (Business module) in an application?
>>
>> While exploring I found that multiple persistence units are created mostly
>> if different entities are packaged in different WAR/JAR/EAR files. Is this
>> the only criteria to have multiple units?
>>
>> Regards,
>>
>> Krishnaprasad (Kp)
>>

Re: Persistence units

Posted by Chris Wolf <cw...@gmail.com>.
Kp,

At the risk of hijacking your thread - I would like to add some
specificity to your question..i.e.
let's say I want to create two separate JAR projects, each has their
own set of entities and persistence unit and, in fact, separate
persistence.xml.  Will this work in a webapp when both resulting jars
are added to the WAR's WEB-INF/lib?  Or must you only have a single
persistence.xml in a given webapp and must implement some merging
process in the build script?

Thanks,

    -Chris

On Mon, Mar 18, 2013 at 9:55 AM, Krishnaprasad Subbarao
<kr...@in.ibm.com> wrote:
> Hello,
>
> I am working on a large application which has around 50 entities and many
> relational tables. We wish to use OpenJPA 2.1 as a Persistence provider.
>
> I would like to know what criteria's should be considered while deciding
> the number of persistence units to be defined in an application. Following
> are my questions about persistence units
>
> 1) What are points to be considered to decide how many persistence units
> should be created in an application?
>
> 2) Is it recommended to have one persistence unit per logical module
> (Business module) in an application?
>
> While exploring I found that multiple persistence units are created mostly
> if different entities are packaged in different WAR/JAR/EAR files. Is this
> the only criteria to have multiple units?
>
> Regards,
>
> Krishnaprasad (Kp)
>