Also irgendwie klappt das ohne Transaktion nicht wirklich...
Wenn ich das so ausführen möchte, ohne Transaction bekomme ich folgende Exception:
Code:
public static List<FeatureModel> getNearestNeighbour4Point(final double[] point, final int nnNumRes,
final String unit, final int featureType, final int withinDistance, final int srid) {
StringBuffer point2 = new StringBuffer();
point2.append(" SDO_GEOMETRY( ");
point2.append(FeatureDB.POINT_GTYPE);
point2.append(", ");
point2.append(srid);
point2.append(", ");
point2.append("SDO_POINT_TYPE( ");
point2.append(point[0]);
point2.append(", ");
point2.append(point[1]);
point2.append(", null), null, null)");
String s = "SELECT feature FROM Feature feature WHERE " +
"(SDO_NN (feature.f_geom, :point2, 'SDO_NUM_RES = :nnNumRes :unit') 1) = 'TRUE' AND " +
"(SDO_WITHHIN_DISTANCE(feature.f_geom, :point2, ' DISTANCE = :withinDistance :unit') = 'TRUE' AND f_ft_id = :featureType";
Session session = HibernateUtil.getCurrentSession();
List<FeatureModel> list = null;
try {
Query query = session.createQuery(s);
query.setString("point", point2.toString());
query.setInteger("nnNumRes", nnNumRes);
query.setString("unit", unit);
query.setInteger("withinDistance", withinDistance);
query.setInteger("featureType", featureType);
query.list();
} catch (Exception e) {
e.printStackTrace();
} finally {
session = null;
}
return list;
}
Code:
org.hibernate.HibernateException: createQuery is not valid without active transaction
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297)
at $Proxy0.createQuery(Unknown Source)
at at.pcd.wam.technologie.persistence.db.FeatureDB.getNearestNeighbour4Point(FeatureDB.java:74)
at at.pcd.wam.technologie.controller.FeatureController.doMatchPoint(FeatureController.java:217)
at at.pcd.wam.technologie.controller.FeatureController.evaluateTrackSegmentList(FeatureController.java:135)
at at.pcd.wam.technologie.batch.RunBatch.main(RunBatch.java:123)