1 package uk.co.concise.maven.hdc.dao;
2
3 import net.sf.hibernate.HibernateException;
4 import net.sf.hibernate.Session;
5 import net.sf.hibernate.Transaction;
6 import uk.co.concise.maven.hdc.model.Point;
7
8
9 /***
10 * Data accessor object for points.
11 * @author martenssonb
12 */
13 public class PointDao {
14
15 /***
16 * Persists a point or updates if it was already persisted.
17 * @param point point to be persisted.
18 */
19 public void saveOrUpdatePoint(Point point) {
20 Session session = HibernateUtil.currentSession();
21 Transaction tx = null;
22 try {
23 tx = session.beginTransaction();
24
25 session.saveOrUpdate(point);
26 tx.commit();
27 } catch (HibernateException e) {
28 HibernateUtil.handleHibernateException(tx, e);
29 } finally {
30 HibernateUtil.closeSession();
31 }
32 }
33
34 }