Search code examples
javajdodatanucleus

Unable to use DataNucleus enhancer without JDO annotations


I am trying DataNucleus with JDO api using only XML to define the persistence model, without adding annotation like @PersistenceCapable. That is something that supposedly supported by both JDO and DataNucleus, if I did understand both documentations.

For instance if I remove all annotations of Book.java, Inventory.java, Product.java in datanucleus example and run mvn clean compile I should get the job done, because package.orm define those classes, but I get the following error for all this classes:

(main) DEBUG [DataNucleus.MetaData] - Class org.datanucleus.samples.jdo.tutorial.Inventory was specified in persistence-unit (maybe by not putting exclude-unlisted-classes) Tutorial but not annotated, so ignoring

....

(main) INFO [DataNucleus.Enhancer] - DataNucleus Enhancer completed with success for 0 classes.

What I am missing?

Actual configuration files:

persistence.xml
...
<persistence-unit name="Tutorial">
    <class>org.datanucleus.samples.jdo.tutorial.Inventory</class>
    <class>org.datanucleus.samples.jdo.tutorial.Product</class>
    <class>org.datanucleus.samples.jdo.tutorial.Book</class>
    <exclude-unlisted-classes/>
    ...
</persistence-unit>
...

package-h2.orm
<orm>
<package name="org.datanucleus.samples.jdo.tutorial">
    <!-- persistence-modifier is by default equal to: persistence-capable -->
    <class name="Inventory" table="INVENTORIES" >...</class>
    <class name="Product" table="PRODUCTS">...</class>
    <class name="Book" table="BOOKS">...</class>
</orm>

Solution

  • ORM metadata is to OVERRIDE JDO metadata. Consequently you need either annotations OR a JDO XML metadata file (package.jdo).

    "class" entries in persistence.xml are to specify classes that have annotations, and you say you have none.

    "mapping-file" entries in persistence.xml are to specify XML metadata files ... and you haven't specified any.