• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Change the Persistence-Unit Properties in Runtime

 
Luciano A. Pozzo
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Luciano A. Pozzo
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you Mark.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic