users@glassfish.java.net

How do I map datasource to JPA Persistence.xml?

From: <glassfish_at_javadesktop.org>
Date: Mon, 07 Jul 2008 15:20:48 PDT

In my persistence.xml I have:

[code]
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
  <persistence-unit name="MyApp-ejbPU" transaction-type="JTA">
    <provider>oracle.toplink.essentials.PersistenceProvider</provider>
    <jta-data-source>jdbc/myapp</jta-data-source>
  </persistence-unit>
</persistence>
[/code]

the "jdbc/myapp" is coded straight in the app server.

But I want to use "jdbc/myapp" in the application, and "jdbc/localdatasource" within the app server.

Normally, that mapping is done in the sun-ejb.xml file, but that's only for EJBs.

How do I do this mapping so it's relevant to persistence.xml? Do I just do the mapping for those EJBs that use EntityManager?
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=284881