Search in sources :

Example 1 with SampleMultiPoint

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

the class PgGeometryMappingTest method testMultiPointMapping.

public void testMultiPointMapping() throws SQLException {
    if (!runTestsForDatastore()) {
        return;
    }
    MultiPoint multipoint = new MultiPoint("SRID=4326;MULTIPOINT(10 10,75 75)");
    SampleMultiPoint sampleMultiPoint;
    SampleMultiPoint sampleMultiPoint_read;
    PersistenceManager pm = pmf.getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    Object id = null;
    try {
        tx.begin();
        sampleMultiPoint = new SampleMultiPoint(4001, "MultiPoint", multipoint);
        pm.makePersistent(sampleMultiPoint);
        id = JDOHelper.getObjectId(sampleMultiPoint);
        sampleMultiPoint = (SampleMultiPoint) pm.detachCopy(sampleMultiPoint);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
    pm = pmf.getPersistenceManager();
    tx = pm.currentTransaction();
    try {
        tx.begin();
        sampleMultiPoint_read = (SampleMultiPoint) pm.getObjectById(id, true);
        assertEquals(sampleMultiPoint, sampleMultiPoint_read);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
}
Also used : MultiPoint(org.postgis.MultiPoint) SampleMultiPoint(org.datanucleus.samples.pggeometry.SampleMultiPoint) SampleMultiPoint(org.datanucleus.samples.pggeometry.SampleMultiPoint) Transaction(javax.jdo.Transaction) PersistenceManager(javax.jdo.PersistenceManager)

Aggregations

PersistenceManager (javax.jdo.PersistenceManager)1 Transaction (javax.jdo.Transaction)1 SampleMultiPoint (org.datanucleus.samples.pggeometry.SampleMultiPoint)1 MultiPoint (org.postgis.MultiPoint)1