GlassFish Server 3.0.1 and Sun GlassFish Enterprise Server v3 use the persistence provider EclipseLink, while earlier versions used TopLink Essentials.
An application that uses the container to create an EntityManager or EntityManagerFactory and that used Toplink Essentials as its provider will work in GlassFish Server 3.0.1. The container creates an EntityManager if the application uses the @PersistenceContext annotation to inject an EntityManager, as in the following example:
@PersistenceContext EntityManager em;
The container creates an EntityManagerFactory if the application uses the @PersistenceUnit annotation to inject an EntityManagerFactory, as in the following example:
@PersistenceUnit EntityManagerFactory emf; EntityManager em = emf.createEntityManager();
When the application is loaded, GlassFish Server 3.0.1 will translate the provider to EclipseLink and will also translate toplink.* properties in the persistence.xml to corresponding EclipseLink properties. (The actual persistence.xml file remains unchanged.)
Under certain circumstances, however, you may have to modify the persistence.xml file or your code:
If your application uses Java SE code to create the EntityManagerFactory, you will need to change your persistence.xml file for both the provider element and for any toplink.* properties to use the EclipseLink equivalents. An application uses Java SE code if it uses the javax.persistence.Persistence class to create the EntityManagerFactory, as in the following example:
EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("Order"); EntityManager em = emf.createEntityManager();
In this case, change the provider element to specify the following:
If the application itself contains any TopLink Essentials-specific code and therefore contains casts to oracle.toplink.*, you must change the code to cast to org.eclipse.persistence.*. You can use the package renamer tool described on the Eclipse wiki to do this. This tool is not provided with GlassFish Server 3.0.1, however, so you must obtain it from the EclipseLink project download site.