use of org.datanucleus.samples.pggeometry.SampleGeometryCollection in project tests by datanucleus.
the class PgGeometryMappingTest method testGeometryCollectionMapping.
public void testGeometryCollectionMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
GeometryCollection geometryCollection = new GeometryCollection("SRID=4326;GEOMETRYCOLLECTION(POINT(10 10),LINESTRING(0 50, 100 50),POLYGON((25 25,75 25,75 75,25 75,25 25),(45 45,55 45,55 55,45 55,45 45)))");
SampleGeometryCollection sampleGeometryCollection;
SampleGeometryCollection sampleGeometryCollection_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
sampleGeometryCollection = new SampleGeometryCollection(7001, "Collection 1", geometryCollection);
pm.makePersistent(sampleGeometryCollection);
id = JDOHelper.getObjectId(sampleGeometryCollection);
sampleGeometryCollection = (SampleGeometryCollection) pm.detachCopy(sampleGeometryCollection);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
sampleGeometryCollection_read = (SampleGeometryCollection) pm.getObjectById(id, true);
assertEquals(sampleGeometryCollection, sampleGeometryCollection_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
Aggregations