List of usage examples for org.hibernate Session load
void load(Object object, Serializable id);
From source file:com.ikon.dao.NodeNoteDAO.java
License:Open Source License
/** * Create//w w w . ja va 2s .c om */ public void create(NodeNote nNote) throws PathNotFoundException, AccessDeniedException, DatabaseException { log.debug("create({})", nNote); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); // Security Check NodeBase parentNode = (NodeBase) session.load(NodeBase.class, nNote.getParent()); SecurityHelper.checkRead(parentNode); SecurityHelper.checkWrite(parentNode); session.save(nNote); HibernateUtil.commit(tx); log.debug("create: void"); } catch (PathNotFoundException e) { HibernateUtil.rollback(tx); throw e; } catch (AccessDeniedException e) { HibernateUtil.rollback(tx); throw e; } catch (DatabaseException e) { HibernateUtil.rollback(tx); throw e; } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.NodeNoteDAO.java
License:Open Source License
/** * Delete// w ww .j a v a 2 s .com */ public void delete(String uuid) throws PathNotFoundException, AccessDeniedException, DatabaseException { log.debug("delete({})", uuid); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); // Security Check NodeBase parentNode = getParentNode(session, uuid); SecurityHelper.checkRead(parentNode); SecurityHelper.checkWrite(parentNode); NodeNote nNote = (NodeNote) session.load(NodeNote.class, uuid); session.delete(nNote); HibernateUtil.commit(tx); } catch (PathNotFoundException e) { HibernateUtil.rollback(tx); throw e; } catch (AccessDeniedException e) { HibernateUtil.rollback(tx); throw e; } catch (DatabaseException e) { HibernateUtil.rollback(tx); throw e; } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } log.debug("delete: void"); }
From source file:com.ikon.dao.NodeNoteDAO.java
License:Open Source License
/** * Get parent node//from w ww.j a v a2s .c o m */ private NodeBase getParentNode(Session session, String uuid) throws HibernateException { log.debug("getParentNode({}, {})", session, uuid); String qs = "select nn.parent from NodeNote nn where nn.uuid=:uuid"; Query q = session.createQuery(qs); q.setString("uuid", uuid); String parentUuid = (String) q.setMaxResults(1).uniqueResult(); NodeBase parentNode = (NodeBase) session.load(NodeBase.class, parentUuid); log.debug("getParentNode: {}", parentNode); return parentNode; }
From source file:com.ikon.dao.OmrDAO.java
License:Open Source License
/** * Delete//from w w w.ja v a2s . c o m */ public void delete(long omId) throws DatabaseException { log.debug("delete({})", omId); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); Omr om = (Omr) session.load(Omr.class, omId); session.delete(om); HibernateUtil.commit(tx); } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } log.debug("delete: void"); }
From source file:com.ikon.dao.ProfileDAO.java
License:Open Source License
/** * Delete//from ww w. j a v a 2 s. c om */ public static void delete(long upId) throws DatabaseException { log.debug("delete({})", upId); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); Profile up = (Profile) session.load(Profile.class, upId); session.delete(up); HibernateUtil.commit(tx); } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } log.debug("delete: void"); }
From source file:com.ikon.dao.QueryParamsDAO.java
License:Open Source License
/** * Create/*from w w w .jav a 2s. co m*/ */ public static long create(QueryParams qp) throws DatabaseException { log.debug("create({})", qp); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); Long id = (Long) session.save(qp); QueryParams qpTmp = (QueryParams) session.load(QueryParams.class, id); for (String keyword : qp.getKeywords()) { qpTmp.getKeywords().add(keyword); } for (String category : qp.getCategories()) { qpTmp.getCategories().add(category); } for (Iterator<Entry<String, String>> it = qp.getProperties().entrySet().iterator(); it.hasNext();) { Entry<String, String> entry = it.next(); qpTmp.getProperties().put(entry.getKey(), entry.getValue()); } HibernateUtil.commit(tx); log.debug("create: {}", id); return id; } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.QueryParamsDAO.java
License:Open Source License
/** * Delete/*from w w w . j a v a2s. c om*/ */ public static void delete(long qpId) throws DatabaseException { log.debug("delete({})", qpId); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); QueryParams qp = (QueryParams) session.load(QueryParams.class, qpId); session.delete(qp); HibernateUtil.commit(tx); } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } log.debug("delete: void"); }
From source file:com.ikon.dao.QueryParamsDAO.java
License:Open Source License
/** * Share//from www . j a v a 2 s . co m */ public static void share(long qpId, String user) throws DatabaseException { log.debug("share({})", qpId); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); QueryParams qp = (QueryParams) session.load(QueryParams.class, qpId); qp.getShared().add(user); session.update(qp); HibernateUtil.commit(tx); log.debug("share: void"); } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.QueryParamsDAO.java
License:Open Source License
/** * Unshare//from ww w . ja va2 s. c om */ public static void unshare(long qpId, String user) throws DatabaseException { log.debug("share({})", qpId); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); QueryParams qp = (QueryParams) session.load(QueryParams.class, qpId); qp.getShared().remove(user); session.update(qp); HibernateUtil.commit(tx); log.debug("share: void"); } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.RegisteredPropertyGroupDAO.java
License:Open Source License
/** * Find by pk//from w w w . java 2 s . c o m */ public RegisteredPropertyGroup findByPk(String grpName) throws DatabaseException { log.debug("findByPk({})", grpName); Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); RegisteredPropertyGroup ret = (RegisteredPropertyGroup) session.load(RegisteredPropertyGroup.class, grpName); initialize(ret); log.debug("findByPk: {}", ret); return ret; } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }