2. JPA Configuration

The persistence-unit is named 'hsql'. When supporting tests and a production database, controlling which persistence unit is loaded can be done with Spring Profiles.

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_0.xsd"
             version="2.0">

    <persistence-unit name="hsql">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
            <property name="hibernate.show_sql" value="true" />
            <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.HashtableCacheProvider" />
            <property name="jadira.usertype.autoRegisterUserTypes" value="true" /> 1
            <property name="jadira.usertype.databaseZone" value="jvm" />
        </properties>
    </persistence-unit>
    
</persistence>
                
            
1 Registering Joda Time custom JPA user types.