Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create new persistence unit at run time?

 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

I am working in Jboss.

I have persistence.xml and in the file i create persistence unit that is mapped to a data source and a schema.

I want to create in run time a new persistence unit and factory , that is mapped to another data source and schema.

I need it because i want to create copy of this unit in different schema for each user that register to the system.

My questions are:
How can i create new persistence unit at run time?

How can i save the new persistence unit that i created to the persistence.xml or to another file in order have them in case the server is crashed?

Can i create a data source that map to a data base url and not mapped to schema and in the persistence unit properties give the schema connection url ?

Thank you very much
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the way things are right now, I don't think you will be able to do this programatically and save it in a persistence.xml.

Mark
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!