2. JPA Configuration

Two persistence-unit elements are defined. One for HSSQL DB and another for PostgreSQL.

META-INF/persistence.xml
                
<?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_1.xsd"
             version="2.1">

    <persistence-unit name="hsql">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />

            <property name="hibernate.hbm2ddl.auto" value="validate" />
            <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
            <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider" />
            <property name="jadira.usertype.autoRegisterUserTypes" value="true" />  1
            <property name="jadira.usertype.databaseZone" value="jvm" />
        </properties>
    </persistence-unit>
    <persistence-unit name="postgresql">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        
        <properties>
            <property name="hibernate.dialect" value="org.springbyexample.orm.dialect.TableNameSequencePostgreSQLDialect" />

            <property name="hibernate.hbm2ddl.auto" value="validate" />
            <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
            <property name="hibernate.max_fetch_depth" value="3" />
            <property name="jadira.usertype.autoRegisterUserTypes" value="true" />
            <property name="jadira.usertype.databaseZone" value="jvm" />
        </properties>
    </persistence-unit>
    
</persistence>
                
            
1 Register Joda DateTime support.