-->
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.  [ 6 posts ] 
Author Message
 Post subject: Persistence.xml, hibernate.archive.autodetection
PostPosted: Thu Feb 21, 2008 8:10 am 
Newbie

Joined: Mon Feb 04, 2008 6:31 am
Posts: 8
Is there any way to control the hibernate.archive.autodetection property?
I have two persistence units in my persistence.xml, and I'd love to instruct the first to autodetect classes only from package.1.orm and the second from package.2.orm.

Is it possible within one application with two separate persistence units without specifying the classes explicitly?

I'm using the latest:
Hibernate Core 3.2.6
Hibernate Annotations 3.3.0
Hibernate EntityManager 3.3.1

If it's not possible, should I care actually? What I'm doing is a DB migration, and I'm moving objects from one DB to another one, hence two persistence units (both providers are org.hibernate.ejb.HibernatePersistence, and I don't think this will change).

Thanks for any tips,


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 21, 2008 12:20 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I think you'll have to list your classes explicitely unless you manage to split your entities into 2 separate jars

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Persistence.xml and orm.xml
PostPosted: Tue Feb 26, 2008 3:19 am 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
I recently had the same problem, and I found that I had to do this:
- create 2 different persistent units in persistence.xml
- disable autodetection for Hibernate
- in each of these persistent units I enlisted the classes which where to map to a unit (with the <class> element
- in each of these persistent units I put a something like[i]<mapping-file>META-INF/orm_xxxx.xml</mapping-file>
, to differentiate the externalized queries to be used be each persistent unit.

So, if you don't want to put the list of mapped classes into persistence.xml, you can put them into an "orm" file.

The most important experience for me was:
- you cannot rely on the "schema" property on the annotated class
- therefore you must prevent Hibernate validation using reflection on the annotated classes (it ignores the schema values!)
- you have to force Hibernate to do validation using the descriptions in persistence.xml and orm.xml.

I also think, there is some mismatch between Hibernate's DDL schema creation tool and Hibernate's runtime validation process; the first one differentiates on the schema values in the annotations, the latter doesn't do this.

Carlo


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 27, 2008 7:42 am 
Newbie

Joined: Mon Feb 04, 2008 6:31 am
Posts: 8
I've managed to split them into two separate jar's - good idea, and now using the <jar-file> property in persitence.xml I've exactly what I've wanted, thanks for your help


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 30, 2008 1:42 pm 
Newbie

Joined: Wed Oct 24, 2007 2:39 pm
Posts: 7
How do you declare the jars ??
A)
Code:
   <persistence-unit name="entityManager" transaction-type="JTA">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>jdbc/xxx</jta-data-source>
<jar-file>first.jar</jar-file>
      <properties>
         <property name="hibernate.ejb.cfgfile" value="/META-INF/hibernate.cfg.xml"/>
      </properties>
   </persistence-unit>

   <persistence-unit name="entityManager2" transaction-type="JTA">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>jdbc/xxx</jta-data-source>
<jar-file>seconde.jar</jar-file>
      <properties>
         <property name="hibernate.ejb.cfgfile" value="/META-INF/hibernate.cfg.xml"/>
      </properties>
   </persistence-unit>



B)
Code:
   <persistence-unit name="entityManager" transaction-type="JTA">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>jdbc/xxx</jta-data-source>
<jar-file>first.jar</jar-file>
<jar-file>second.jar</jar-file>
      <properties>
         <property name="hibernate.ejb.cfgfile" value="/META-INF/hibernate.cfg.xml"/>
      </properties>
   </persistence-unit>



?


Top
 Profile  
 
 Post subject: Re: Persistence.xml, hibernate.archive.autodetection
PostPosted: Fri May 01, 2009 6:59 pm 
Newbie

Joined: Fri May 01, 2009 6:54 pm
Posts: 1
Can you provide an example of the persistence.xml file? I'm trying to use two persistence-units and can't get Hibernate to not scan both jars twice...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.