users@glassfish.java.net

Re: Persistence.xml - Convert from JPA 1.0 to 2.0

From: Alexis Moussine-Pouchkine <alexis.mp_at_sun.com>
Date: Tue, 23 Feb 2010 21:31:28 +0100

This sounds like a reasonable persistence.xml (including the EclipseLink provider name) :

> <?xml version="1.0" encoding="UTF-8"?>
> <persistence 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"
> version="2.0">
> <persistence-unit name="persistenceUnit" transaction-type="JTA">
> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

Note the JPA 2.0 schema ships with the GlassFish distro (glassfish/lib/schemas/persistence_2_0.xsd)

hth,
-Alexis

On 23 févr. 2010, at 16:14, glassfish_at_javadesktop.org wrote:

> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>