use of org.datanucleus.samples.pggeometry.SampleGeometry in project tests by datanucleus.
the class PgGeometryMappingTest method testGeometryMapping.
public void testGeometryMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
Point point = new Point("SRID=4326;POINT(10 10)");
SampleGeometry sampleGeometry;
SampleGeometry sampleGeometry_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
sampleGeometry = new SampleGeometry(1001, "Geometry (Point)", point);
pm.makePersistent(sampleGeometry);
id = JDOHelper.getObjectId(sampleGeometry);
sampleGeometry = (SampleGeometry) pm.detachCopy(sampleGeometry);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
sampleGeometry_read = (SampleGeometry) pm.getObjectById(id, true);
assertEquals(sampleGeometry, sampleGeometry_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
Aggregations