-->
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.  [ 4 posts ] 
Author Message
 Post subject: Dynamic units within persistence.xml ?
PostPosted: Thu Jan 11, 2007 6:16 pm 
Newbie

Joined: Sun Dec 17, 2006 6:30 pm
Posts: 9
Hello,

In Hibernate 3.2 (JBoss 4.0.4 AS), is it possible to have no persistence unit (or only one) in the persistence.xml and then to load another persistence unit with another datasource at runtime ?

You could ask me : Why ?
So, this is just to deploy an entities.jar on many servers in which there are connections to database with distinct names depending on the client and so, when I build the entities.jar, I don't know the database names ! So, I can fix the datasources and the units in the persistence.xml, but when I will update the entities.jar, the persistence.xml will be overwrite !

Thanks,

Olivier


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 12, 2007 8:05 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you can use <jar-file>entities.jar</jar-file> and inclue this jar in your EAR. The persistence jar will be specific to each client but entities.jar will be the same.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 15, 2007 5:18 pm 
Newbie

Joined: Sun Dec 17, 2006 6:30 pm
Posts: 9
Ok, thanks for your reply.
I have tried to use the <jar-file> tag in the persistence.xml but when I use it, I must set the path from the path where JBoss is running (run.bat in windows) and not from the deploy dir, is it normal ?

So, ok, the "update entities.jar problem" is resolved but another one is related to it :
For example, in one server, the session/entity beans will be used only by one client and so, it will access only one database. But in another server, the session/entity beans may be used by two or more clients and so, it will access two or more databases. And for the moment, from time to time,
some clients add themselves access to database to the software which is used (a visual basic soft) until the Java EE will be used.

So, two questions :
1) Is it possible to avoid to use the @PersistenceContext(unitName="xxxxx") annotation in the session beans and to tell to the entity manager which persistence unit to use and to reload the entities in memory ? Perhaps, using the EntityManagerFactory ?
2) Is it possible to modify the persistence.xml with a session bean to add/modify/delete a persistence unit and then to reload the ear in memory (if the ear is not compress in one file but deploy in a directory) ?

Thanks.

Olivier


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 21, 2007 8:19 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
this is a known issue

You'll have to map the emf to a jndi name and do the lookup entitymanager opening and closing yourself

_________________
Emmanuel


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