-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Unable to dispatch entities in diffrent jars for the same PU
PostPosted: Fri Feb 05, 2010 4:54 am 
Newbie

Joined: Wed Feb 03, 2010 10:47 am
Posts: 1
Hi,

Dispatching entities in different modules is not really easy with Hibernate/JPA, so I need your help.

For people using Spring, there is a common tweak to do this (http://ancientprogramming.blogspot.com/ ... s-and.html), but it don't work anymore with Hibernate 3.5 (http://opensource.atlassian.com/project ... e/HHH-4864).

I raised this point on Hibernate dev list, and would like to continue the discussion here. Emmanuel Bernard answer me that :
Quote:
Splitting entities amongst several JARs is definitely supported by JPA 2, you need to use the <jar-file> element in persistence.xml (or to a lesser extend <class>).
Merging several persistence.xml and considering them one is not a concept that makes sense in the JPA 2 spec. Conceptually that means a lot of metadata duplication that can and will conflict.
The exception you see comes from the fact that your "merging" does not "unduplicate" jar file urls and it's associated root url.


For my user point of view :
    jar-file is not usable in real life, mainly because when you activate m2eclipse workspace resolution, mylib.jar change to file:.../mylib/target/classes
    I want to keep a single Datasource, EntityManager and TransactionManager, so in my need one PU is good
    I want to allow people to add Entities just by adding a JAR in the classpath (plugin way). Since I don't know Entity classes names when providing the core of my app, I can't use <class>
    It seems JPA2 don't offer a solution for this (common) need when you are building multi modules applications

Has somebody a workaround for this issue with Hibernate 3.5 ?


Top
 Profile  
 
 Post subject: Re: Unable to dispatch entities in diffrent jars for the same PU
PostPosted: Fri Feb 05, 2010 9:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I understand your usecase, but without scanning the *complete* classpath how do you expect this to work ?

It will be immensely slow.

The sanctioned way is to as emmanuel pointed you to is have persistence.xml list the jar-files you want included in the scanning.
Anything else will result in non-determinism and (too) slow startup.

This might not be all dynamic, how often are you going to add a new .jar ?

But that of course leave you with the problem of what to do when running in an IDE where you don't actually have jar (your m2eclipse example is one case of that, but it is actually not tied to maven either)

For that I don't have a good answer - emmanuel, anyway we could "teach" persistence.xml scanning that when referiing to x.jar it should actually look somewhere else ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Unable to dispatch entities in diffrent jars for the same PU
PostPosted: Thu Mar 25, 2010 4:56 pm 
Newbie

Joined: Thu Mar 25, 2010 10:25 am
Posts: 1
I disagree with performance overhead. I use the code described in http://ancientprogramming.blogspot.com/ ... s-and.html. I have projects with 10 to 20 modules containing a persistence.xml file with the same name. Using spring 3 + hibernate 3.3.1 I deploy my applications 2 to 3 times faster compared to the same code using a EJB3/multiple persistence unit name application on JBossEmbedded or OpenEJB. This is very important to speed up the development process(for instance). Moreover, I have better interactions with m2eclipse plugin. Actually, it is efficient because only jars (or projects) containing a persistence.xml file are selected for scanning.

As stated by bouiaw, merging persistence units with the same name is very common in Spring/JPA (Hibernate) applications, and actually it makes sense. If I don't want a merging I use a different name ...
When possible I will try to write my own scanning approach following Emmanuel suggestions (http://lists.jboss.org/pipermail/hibern ... 04813.html)

regards
Vincent


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.