use of org.datanucleus.samples.jtsgeometry.SampleLineString in project tests by datanucleus.
the class JtsGeometryMappingTest method testLineStringMapping.
public void testLineStringMapping() throws SQLException, ParseException {
if (!runTestsForDatastore()) {
return;
}
LineString lineString = (LineString) wktReader.read("LINESTRING(0 50,100 50)");
SampleLineString sampleLineString;
SampleLineString sampleLineString_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
sampleLineString = new SampleLineString(2001, "LineString 1", lineString);
pm.makePersistent(sampleLineString);
id = JDOHelper.getObjectId(sampleLineString);
sampleLineString = (SampleLineString) pm.detachCopy(sampleLineString);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
sampleLineString_read = (SampleLineString) pm.getObjectById(id, true);
assertEquals(sampleLineString, sampleLineString_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
Aggregations