On 29/10/2007, Jeff Mutonho <[EMAIL PROTECTED]> wrote:
>
>
>
> On 10/29/07, Vusa Dube <[EMAIL PROTECTED]> wrote:
> >
> > Hi guys,
> > I'm slowly migrating a JSP/JDBC application to my new found love, JPA
> > and I'm loving it. I'm making my first babysteps in JPA.
> >
> > Previously, when a user logs in, the application looks up their name in
> > the main database, and obtains the database they're supposed to use and
> > creates a new Connection object on that database which can then be passed to
> > any method that needs to use it. This way, I determine the database to use
> > at runtime.
> >
> > With JPA, I see I need to define a persistence unit in the
> > persistence.xml file for each database. Is there a way of defining one
> > persistence unit and then pass the database name as a parameter at runtime?
> > I'm looking at something like setting the database property for the
> > EntityManagerFactory object (I'm manually creating the EntityManager object
> > since I'm doing some of this stuff in JSP's).
> >
> >
> > Vusi.
> >
> >
> > Can't you use 
> > http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManagerFactory.html#createEntityManager(java.util.Map)
>
> <http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManagerFactory.html#createEntityManager%28java.util.Map%29>
> to achieve the same effect?



Great stuff Jeff! Works like a charm;)

I tried to search around for configurable properties that I put in the map,
but couldn't find good documentation on it (read idiot's guide). Somehow I
thought I could only put certain parameters in the map but not the url.
Silly me.

Thanks.

Vusi.


"Don't take the name of root in vain."
>
> Jeff  Mutonho
> Cape Town
> South Africa
>
> GoogleTalk : ejbengine
> Skype        : ejbengine
> Registered Linux user number 366042
> >
>


-- 
"I'll be more enthusiastic about encouraging thinking outside the box when
there's evidence of any thinking going on inside it."
- Terry Pratchett

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CTJUG Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/CTJUG-Forum
For the ctjug home page see http://www.ctjug.org.za
-~----------~----~----~----~------~----~------~--~---

Reply via email to