Home » Support » Forum » mapping file is not being loaded

mapping file is not being loaded


Hi, I am evaluating ObjectDB by using it with an in-house developed library in order to prototype its capabilities / performance.

I am having a problem in that the in-house library in question reads a simple configuration file to determine available persistence units, and then bootstraps them using the JPA Persistance.createEntityManagerFactory() method and passing in the persistence unit name (again, obtained from the configuration file ).

After the entity manager factory is obtained, the Metamodel is empty - none of the entities referenced in the mapping file are present in the Metamodel.


here is my persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    <persistence-unit name="project.odb" >
            <property name="javax.persistence.jdbc.url" value="objectdb://localhost:6136/project.odb" />
            <property name="javax.persistence.jdbc.user" value="admin"/>
            <property name="javax.persistence.jdbc.password" value="admin" />


The entities are mapped in the ORM.xml file correctly, as they work with the previous hibernate implementation.

the java code that interacts with the Persistence api:

EntityManagerFactory emf = Persistence.createEntitManagerFactory("project.odb");

//this set is alwasy empty with ObjectDB
Set<EntityType> managedEntities = emf.getMetaModel().getEntities();


I am certain that this must be a configuration issue, although I am using the default configuration file with no changes.





Please check if listing the entity classes in the persistence.xml file makes any difference.

Another thing to check - setting exclude-unlisted-classes to false rather than true.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

After being pulled away from this project for a few months, I have been able to (finally) return and attempt to address this issue.  I have followed both suggestions - manually listing classes along with setting exclude-unlisted-classes to false.

The Metamodel API still returns the empty set when 'getEntities()' is invoked.

The prototype is running in a  Tomcat server with a RESOURCE_LOCAL transaction scope over a plain JDBC connection.

The entity classes use no JPA annotations, as some of our internal guidelines call for the xml mapping files only, and this is an important requirement.

ObjectDB itself is running in client-server mode using configuration contained in the default location (objectdb root directory).

Both objectdb.jar and objectdb-jee.jar are on the classpath.

Finally, the application prototype is being deployed as a war, with objectdb jars on the WAR lib directory.

Any suggestions would be appreciated.




Try changing the unit name from project.odb to project, to see if the persistence unit is found.

The special odb suffix is interpreted by ObjectDB also as a direct database path, so if the persistence unit is not found a virtual persistence unit is used and no error is produced.

Did you try anything else except using the Metamodel API (storing objects, etc)? Does it work?

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

So I changed the persistence unit name by removing the .odb extension, and then wrote a simple unit test that created one of my project's entity classes and persisted it.  After running the unit test, the Metamodel data for any other entity class that was reachable from the one I persisted was available via the Metamodel API.  I then removed the explicit class listings, and re-set the exclude-unlisted-classes configuration element back to false, and ran the original project.  The metadata was now accessible.

So it appears then that Metamodel for a given Entity is unavailable until 1.) an instance of that Entity is persisted or 2.) the given entity is reachable by another persisted entity.  Is this correct?



Giving the following persistence unit definition:

<persistence-unit name="T824" >
   <property name="javax.persistence.jdbc.url" value="objectdb://localhost/db/test.tmp;drop" />
   <property name="javax.persistence.jdbc.user" value="admin" />
   <property name="javax.persistence.jdbc.password" value="admin" />

This simple program:

import javax.persistence.Entity;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class T824 {

    public static void main(String[] args) {
        EntityManagerFactory emf =

    public static class A {

produces the following output:

[Type T824$A]

So the metadata is available even though the database is still empty.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login