3. JPA Configuration

Hibernate is setup as the JPA provider. Another JPA provider, like EclipseLink, could be specified and if all your code just uses JPA nothing else would need to be changed. The Person & Address classes are explicitly configured, and JPA's scanning for entity beans is turned off by specifying the exclude-unlisted-classes element. Some Hibernate specific configuration items are set within the properties element.

Excerpt from 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_1_0.xsd"
             version="1.0">

    ...
    
    <persistence-unit name="inheritance-jpa">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <class>org.springbyexample.orm.jpa.inheritance.bean.Student</class>
        <class>org.springbyexample.orm.jpa.inheritance.bean.Professional</class>
        <class>org.springbyexample.orm.jpa.inheritance.bean.Address</class>
        
        <exclude-unlisted-classes/>
         
        <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" />
        </properties>
    </persistence-unit>
    
</persistence>