Search in sources :

Example 1 with PGbox3d

use of org.postgis.PGbox3d in project tests by datanucleus.

the class PgGeometryPostGISExtMappingTest method testBoxMapping.

public void testBoxMapping() throws SQLException {
    if (!runTestsForDatastore()) {
        return;
    }
    PGbox2d pgbox2d = new PGbox2d(new Point(10, 10), new Point(20, 20));
    PGbox3d pgbox3d = new PGbox3d(new Point(20, 20, 100), new Point(30, 30, 100));
    SampleBox sampleBox;
    SampleBox sampleBox_read;
    PersistenceManager pm = pmf.getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    Object id = null;
    try {
        tx.begin();
        sampleBox = new SampleBox(1001, "PGboxes", pgbox2d, pgbox3d);
        pm.makePersistent(sampleBox);
        id = JDOHelper.getObjectId(sampleBox);
        sampleBox = (SampleBox) pm.detachCopy(sampleBox);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
    pm = pmf.getPersistenceManager();
    tx = pm.currentTransaction();
    try {
        tx.begin();
        sampleBox_read = (SampleBox) pm.getObjectById(id, true);
        assertEquals(sampleBox, sampleBox_read);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
}
Also used : Transaction(javax.jdo.Transaction) PGbox2d(org.postgis.PGbox2d) PersistenceManager(javax.jdo.PersistenceManager) PGbox3d(org.postgis.PGbox3d) SampleBox(org.datanucleus.samples.pggeometry.SampleBox) Point(org.postgis.Point)

Aggregations

PersistenceManager (javax.jdo.PersistenceManager)1 Transaction (javax.jdo.Transaction)1 SampleBox (org.datanucleus.samples.pggeometry.SampleBox)1 PGbox2d (org.postgis.PGbox2d)1 PGbox3d (org.postgis.PGbox3d)1 Point (org.postgis.Point)1