File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Change the Persistence-Unit Properties in Runtime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Change the Persistence-Unit Properties in Runtime" Watch "Change the Persistence-Unit Properties in Runtime" New topic
Author

Change the Persistence-Unit Properties in Runtime

Luciano A. Pozzo
Ranch Hand

Joined: Jun 20, 2005
Posts: 112
Hi all,

There is a way to change the Persistence-Unit properties in runtime(via jmx)? Or pass by argument without open the persistence.xml?


example, the property hibernate.show_sql




ps. I am using JBoss.


thanks
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Well it is usually a one to one relationship between a PersistenceUnit/EntityManagerFactory/Database, so when you create an EntityManagerFactory it is immutable, meaning you can't change it once it is created, and this is how it should be. If you want to point to different databases at runtime, you will need a persistence unit per database, then you might be able to write code that gets an EntityManager from one of the existing persistence units.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Luciano A. Pozzo
Ranch Hand

Joined: Jun 20, 2005
Posts: 112
thank you Mark.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Change the Persistence-Unit Properties in Runtime
 
Similar Threads
EJB 3 deployment Error
Exception while deploying the bean
Could not resolve a persistence unit corresponding to the persistence-context-ref-name
Problem javax.persistence.NoResultException: No entity found for query
Problem with Mapping between 1 bit column and boolean field