use of org.datanucleus.samples.pggeometry.SampleLinearRing in project tests by datanucleus.
the class PgGeometryMappingTest method testLinearRingMapping.
public void testLinearRingMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
LinearRing linearRing = new LinearRing(new Point[] { new Point(0, 0), new Point(10, 0), new Point(10, 10), new Point(0, 10), new Point(0, 0) });
linearRing.setSrid(4326);
SampleLinearRing sampleLinearRing;
SampleLinearRing sampleLinearRing_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
sampleLinearRing = new SampleLinearRing(2101, "LinearRing", linearRing);
pm.makePersistent(sampleLinearRing);
id = JDOHelper.getObjectId(sampleLinearRing);
sampleLinearRing = (SampleLinearRing) pm.detachCopy(sampleLinearRing);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
sampleLinearRing_read = (SampleLinearRing) pm.getObjectById(id, true);
assertEquals(sampleLinearRing, sampleLinearRing_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
Aggregations