Search in sources :

Example 1 with SampleGeometryM

use of org.datanucleus.samples.jgeometry.SampleGeometryM in project tests by datanucleus.

the class JGeometry3dMMappingTest method testPoint3DMapping.

public void testPoint3DMapping() throws SQLException {
    if (!runTestsForDatastore()) {
        return;
    }
    JGeometry point = new JGeometry(10.0, 10.0, 100.0, 4326);
    SampleGeometryM samplePoint;
    SampleGeometryM samplePoint_read;
    PersistenceManager pm = pmf.getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    Object id = null;
    try {
        tx.begin();
        samplePoint = new SampleGeometryM(1201, "Point 3D", point);
        pm.makePersistent(samplePoint);
        id = JDOHelper.getObjectId(samplePoint);
        samplePoint = (SampleGeometryM) pm.detachCopy(samplePoint);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
    pm = pmf.getPersistenceManager();
    tx = pm.currentTransaction();
    try {
        tx.begin();
        samplePoint_read = (SampleGeometryM) pm.getObjectById(id, true);
        assertEquals(samplePoint, samplePoint_read);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
}
Also used : Transaction(javax.jdo.Transaction) PersistenceManager(javax.jdo.PersistenceManager) JGeometry(oracle.spatial.geometry.JGeometry) SampleGeometryM(org.datanucleus.samples.jgeometry.SampleGeometryM)

Aggregations

PersistenceManager (javax.jdo.PersistenceManager)1 Transaction (javax.jdo.Transaction)1 JGeometry (oracle.spatial.geometry.JGeometry)1 SampleGeometryM (org.datanucleus.samples.jgeometry.SampleGeometryM)1