users@glassfish.java.net

Persistence.xml - Convert from JPA 1.0 to 2.0

From: <glassfish_at_javadesktop.org>
Date: Tue, 23 Feb 2010 07:14:35 PST

Hello,
I have a Java EE 6 Application on Glassfish V3.
In order to leverage JPA and share my entities, I am using a Persistence.jar (Persistence Unit) packaged and placed inside my .war file's lib directory.


Prior to using Glassfish V3, I had my persistence unit's persistence.xml file created very similar to:

[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="persistenceUnit">
       <jta-data-source>jdbc/myGlassfishDataSourceName</jta-data-source>
  </persistence-unit>

</persistence>
[/code]

One Question being - I've seen a few examples where the header information for JPA 2.0 is completely left out. Is that all optional now? (will glassfish just use the 2.0? xsd)

Or -- should I just use this:
[code]
<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_2_0.xsd">
[/code]

In this case I notice that this http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd doesn't exist.

Thanks for any suggestions
[Message sent by forum member 'hoffman462' (HoffmanDanielG_at_gmail.com)]

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