Search in sources :

Example 1 with TestDataElement

use of org.hibernate.spatial.testing.TestDataElement in project hibernate-orm by hibernate.

the class TestStoreRetrieveUsingGeolatte method storeTestObjects.

private void storeTestObjects(Map<Integer, GeomEntity> stored) {
    Session session = null;
    Transaction tx = null;
    int id = -1;
    try {
        session = openSession();
        // to improve feedback in case of failure
        for (TestDataElement element : testData) {
            id = element.id;
            tx = session.beginTransaction();
            GeomEntity entity = GeomEntity.createFrom(element);
            stored.put(entity.getId(), entity);
            session.save(entity);
            tx.commit();
        }
    } catch (Exception e) {
        if (tx != null) {
            tx.rollback();
        }
        throw new RuntimeException("Failed storing testsuite-suite object with id:" + id, e);
    } finally {
        if (session != null) {
            session.close();
        }
    }
}
Also used : Transaction(org.hibernate.Transaction) TestDataElement(org.hibernate.spatial.testing.TestDataElement) WktDecodeException(org.geolatte.geom.codec.WktDecodeException) Session(org.hibernate.Session)

Example 2 with TestDataElement

use of org.hibernate.spatial.testing.TestDataElement in project hibernate-orm by hibernate.

the class TestStoreRetrieveUsingJTS method storeTestObjects.

private void storeTestObjects(Map<Integer, GeomEntity> stored) {
    Session session = null;
    Transaction tx = null;
    int id = -1;
    try {
        session = openSession();
        // to improve feedback in case of failure
        for (TestDataElement element : testData) {
            id = element.id;
            tx = session.beginTransaction();
            GeomEntity entity = GeomEntity.createFrom(element);
            stored.put(entity.getId(), entity);
            session.save(entity);
            tx.commit();
        }
    } catch (Exception e) {
        if (tx != null) {
            tx.rollback();
        }
        throw new RuntimeException("Failed storing testsuite-suite object with id:" + id, e);
    } finally {
        if (session != null) {
            session.close();
        }
    }
}
Also used : Transaction(org.hibernate.Transaction) TestDataElement(org.hibernate.spatial.testing.TestDataElement) ParseException(com.vividsolutions.jts.io.ParseException) Session(org.hibernate.Session)

Example 3 with TestDataElement

use of org.hibernate.spatial.testing.TestDataElement in project hibernate-orm by hibernate.

the class SDOTestDataReader method addDataElement.

@Override
protected void addDataElement(Element element, List<TestDataElement> testDataElements) {
    int id = Integer.parseInt(element.selectSingleNode("id").getText());
    String type = element.selectSingleNode("type").getText();
    String wkt = element.selectSingleNode("wkt").getText();
    String sdo = element.selectSingleNode("sdo").getText();
    TestDataElement testDataElement = new SDOTestDataElement(id, type, wkt, sdo);
    testDataElements.add(testDataElement);
}
Also used : TestDataElement(org.hibernate.spatial.testing.TestDataElement)

Aggregations

TestDataElement (org.hibernate.spatial.testing.TestDataElement)3 Session (org.hibernate.Session)2 Transaction (org.hibernate.Transaction)2 ParseException (com.vividsolutions.jts.io.ParseException)1 WktDecodeException (org.geolatte.geom.codec.WktDecodeException)1