Sun GlassFish Enterprise Server v2.1.1 Developer's Guide

Changing the Persistence Provider

Note –

The previous sections in this chapter apply only to the default persistence provider. If you change the provider for a module or application, the provider-specific database properties, query hints, and schema generation features described in this chapter do not apply.

The verifier utility always uses the default provider to verify persistence settings. For information about the verifier utility, see The verifier Utility in Sun GlassFish Enterprise Server v2.1.1 Application Deployment Guide.

You can change the persistence provider for an application in the manner described in the Java Persistence API Specification.

First, install the provider. Copy the provider JAR files to the domain-dir/lib directory, and restart the Enterprise Server. For more information about the domain-dir/lib directory, see Using the Common Class Loader. The new persistence provider is now available to all modules and applications deployed on servers that share the same configuration. However, the default provider remains the same.

In your persistence unit, specify the provider and any properties the provider requires in the persistence.xml file. For example:

<?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="">
        <persistence-unit name ="em3">
                <property name="" value="MyDB"/>