persistence@glassfish.java.net

Re: choosing persistence unit at runtime?

From: jeff <jeffrey.blattman_at_yahoo.com>
Date: Tue, 27 Feb 2007 14:00:03 -0800 (PST)

hi craig,

is that something i can do at runtime? i don't want to sound unappreciative of the idea, but bundling the same class files into multiple JAR files probably isn't something i could get away with.

regardless, the idea of having persistence.xml embedded in a JAR file is not realistic for standalone use. the consumer of the persistence unit will need to customize persistence.xml to point to the database server they are interested in. unjarring, rejarring isn't practical.

thanks.

Craig L Russell <Craig.Russell_at_Sun.COM> wrote: You might consider putting the persistence.xml file into a jar file of its own (a different jar file for each persistence.xml you want). Then, select the jar file (with its persistence.xml inside) by prepending it to your class path.

Craig

On Feb 27, 2007, at 1:23 PM, jeff wrote:

if i am using java persistence stand alone, am i able to choose the persistence unit at runtime?

i can't see how to do this, because it appears that the persistence.xml file is read from the classpath.

any ideas?
thanks.


  


---------------------------------
The fish are biting.
  Get more visitors on your site using Yahoo! Search Marketing.

 Craig Russell
 Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
 408 276-5638 mailto:Craig.Russell_at_sun.com
 P.S. A good JDO? O, Gasp!
  




 
---------------------------------
Don't be flakey. Get Yahoo! Mail for Mobile and
always stay connected to friends.