use of org.datanucleus.samples.pggeometry.SampleMultiPolygon in project tests by datanucleus.
the class PgGeometryMappingTest method testMultiPolygonMapping.
public void testMultiPolygonMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
MultiPolygon multiPolygon = new MultiPolygon("SRID=4326;MULTIPOLYGON(((25 25,75 25,75 75,25 75,25 25),(45 45,55 45,55 55,45 55,45 45)),((75 75,100 75,100 100,75 75)))");
SampleMultiPolygon sampleMultiPolygon;
SampleMultiPolygon sampleMultiPolygon_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
sampleMultiPolygon = new SampleMultiPolygon(6001, "MultiPolygon", multiPolygon);
pm.makePersistent(sampleMultiPolygon);
id = JDOHelper.getObjectId(sampleMultiPolygon);
sampleMultiPolygon = (SampleMultiPolygon) pm.detachCopy(sampleMultiPolygon);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
sampleMultiPolygon_read = (SampleMultiPolygon) pm.getObjectById(id, true);
assertEquals(sampleMultiPolygon, sampleMultiPolygon_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
Aggregations