Search in sources :

Example 1 with OEntityManager

use of com.orientechnologies.orient.core.entity.OEntityManager in project orientdb by orientechnologies.

the class OJPAPersistenceProvider method createContainerEntityManagerFactory.

@SuppressWarnings("unchecked")
@Override
public synchronized EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map map) {
    OJPAProperties properties = ((info == null) ? new OJPAProperties() : (OJPAProperties) info.getProperties());
    // Override parsed properties with user specified
    if (map != null && !map.isEmpty()) {
        properties.putAll(map);
    }
    // register entities from <class> tag
    OEntityManager entityManager = getEntityManagerByDatabaseURL(properties.getURL());
    entityManager.registerEntityClasses(info.getManagedClassNames());
    return new OJPAEntityManagerFactory(properties);
}
Also used : OEntityManager(com.orientechnologies.orient.core.entity.OEntityManager)

Example 2 with OEntityManager

use of com.orientechnologies.orient.core.entity.OEntityManager in project orientdb by orientechnologies.

the class OPersistentEmbeddedMapTest method setup.

@BeforeMethod
public void setup() {
    final String url = "memory:tmpdb";
    new OObjectDatabaseTx(url).create().close();
    pool = new OPartitionedDatabasePool(url, "admin", "admin");
    OObjectDatabaseTx db = new OObjectDatabaseTx(pool.acquire());
    try {
        db.setAutomaticSchemaGeneration(true);
        OEntityManager entityManager = db.getEntityManager();
        entityManager.registerEntityClass(Car.class);
        entityManager.registerEntityClass(Person.class);
        db.getMetadata().getSchema().synchronizeSchema();
    } finally {
        db.close();
    }
}
Also used : OEntityManager(com.orientechnologies.orient.core.entity.OEntityManager) OPartitionedDatabasePool(com.orientechnologies.orient.core.db.OPartitionedDatabasePool) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

OEntityManager (com.orientechnologies.orient.core.entity.OEntityManager)2 OPartitionedDatabasePool (com.orientechnologies.orient.core.db.OPartitionedDatabasePool)1 BeforeMethod (org.testng.annotations.BeforeMethod)1