wood burning stoves 2.0*
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: 17250
    
    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.
 
Consider Paul's rocket mass heater.
 
subject: Change the Persistence-Unit Properties in Runtime