How to auto detect entities in JPA 2.0

You need add to the persistence.xml the next line:

<exclude-unlisted-classes>false</exclude-unlisted-classes>

e.g.

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" ...>
    <persistence-unit name="YourPU" ...>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="eclipselink.logging.level" value="ALL"/>
            <property name="eclipselink.ddl-generation" 
                value="drop-and-create-tables"/>
        </properties>
    </persistence-unit>
</persistence>

Leave a Comment