Search in sources :

Example 1 with SampleGeometryCollection3D

use of org.datanucleus.samples.pggeometry.SampleGeometryCollection3D in project tests by datanucleus.

the class PgGeometryPostGISExtMappingTest method testGeometryCollection3DMapping.

public void testGeometryCollection3DMapping() throws SQLException {
    if (!runTestsForDatastore()) {
        return;
    }
    SampleGeometryCollection3D sampleGeometryCollection;
    SampleGeometryCollection3D sampleGeometryCollection_read;
    PersistenceManager pm = pmf.getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    Object id = null;
    try {
        tx.begin();
        sampleGeometryCollection = new SampleGeometryCollection3D(7101, "Collection of 3-dimensional geometries", new GeometryCollection("SRID=-1;GEOMETRYCOLLECTION(POINT(10 10 100),LINESTRING(0 50 100, 100 50 100),POLYGON((25 25 100,75 25 100,75 75 100,25 75 100,25 25 100),(45 45 100,55 45 100,55 55 100,45 55 100,45 45 100)))"));
        pm.makePersistent(sampleGeometryCollection);
        id = JDOHelper.getObjectId(sampleGeometryCollection);
        sampleGeometryCollection = (SampleGeometryCollection3D) pm.detachCopy(sampleGeometryCollection);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
    pm = pmf.getPersistenceManager();
    tx = pm.currentTransaction();
    try {
        tx.begin();
        sampleGeometryCollection_read = (SampleGeometryCollection3D) pm.getObjectById(id, true);
        assertEquals(sampleGeometryCollection, sampleGeometryCollection_read);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
}
Also used : GeometryCollection(org.postgis.GeometryCollection) Transaction(javax.jdo.Transaction) PersistenceManager(javax.jdo.PersistenceManager) SampleGeometryCollection3D(org.datanucleus.samples.pggeometry.SampleGeometryCollection3D)

Aggregations

PersistenceManager (javax.jdo.PersistenceManager)1 Transaction (javax.jdo.Transaction)1 SampleGeometryCollection3D (org.datanucleus.samples.pggeometry.SampleGeometryCollection3D)1 GeometryCollection (org.postgis.GeometryCollection)1