List of usage examples for org.hibernate Query setInteger
@Deprecated @SuppressWarnings("unchecked") default Query<R> setInteger(String name, int val)
From source file:com.openkm.extension.dao.ProposedSubscriptionDAO.java
License:Open Source License
/** * Mark proposed as accepted// ww w . j av a 2 s .co m */ public static void markAccepted(int psId) throws DatabaseException { log.debug("markAccepted({})", psId); String qs = "update ProposedSubscriptionReceived ps set ps.accepted=:accepted where ps.id=:id"; Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery(qs); q.setInteger("id", psId); q.setBoolean("accepted", true); q.executeUpdate(); log.debug("markAccepted: void"); } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.openkm.extension.dao.StampImageDAO.java
License:Open Source License
/** * Active/*from ww w . ja v a 2 s . c om*/ */ public static void active(int siId, boolean active) throws DatabaseException { log.debug("active({}, {})", siId, active); String qs = "update StampImage si set si.active=:active where si.id=:id"; Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); Query q = session.createQuery(qs); q.setBoolean("active", active); q.setInteger("id", siId); q.executeUpdate(); HibernateUtil.commit(tx); } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } log.debug("active: void"); }
From source file:com.openkm.extension.dao.StampImageDAO.java
License:Open Source License
/** * Find by pk/*from w w w . j a v a 2 s. co m*/ */ public static StampImage findByPk(int siId) throws DatabaseException { log.debug("findByPk({})", siId); String qs = "from StampImage si where si.id=:id"; Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); Query q = session.createQuery(qs); q.setInteger("id", siId); StampImage ret = (StampImage) q.setMaxResults(1).uniqueResult(); HibernateUtil.commit(tx); log.debug("findByPk: {}", ret); return ret; } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.openkm.extension.dao.StampTextDAO.java
License:Open Source License
/** * Active/* w w w. ja v a 2s . c om*/ */ public static void active(int stId, boolean active) throws DatabaseException { log.debug("active({}, {})", stId, active); String qs = "update StampText st set st.active=:active where st.id=:id"; Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); Query q = session.createQuery(qs); q.setBoolean("active", active); q.setInteger("id", stId); q.executeUpdate(); HibernateUtil.commit(tx); } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } log.debug("active: void"); }
From source file:com.openkm.extension.dao.StampTextDAO.java
License:Open Source License
/** * Find by pk//from w ww .jav a 2 s. com */ public static StampText findByPk(int stId) throws DatabaseException { log.debug("findByPk({})", stId); String qs = "from StampText st where st.id=:id"; Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery(qs); q.setInteger("id", stId); StampText ret = (StampText) q.setMaxResults(1).uniqueResult(); log.debug("findByPk: {}", ret); return ret; } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.painiu.core.dao.hibernate.PhotoDAOHibernate.java
License:Open Source License
public List getInterestingnessPhotoIdsGroupByDate(final Date fromDate, final Date toDate, final int limit) { return (List) getReadOnlyHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { Query queryObject = session.getNamedQuery("getPhotoInterestingGroupByDate"); queryObject.setInteger("limit", limit); queryObject.setTimestamp("fromDate", fromDate); queryObject.setTimestamp("toDate", toDate); return queryObject.list(); }//from w w w . j a va 2s. c o m }); }
From source file:com.pizzaria.restaurante.dao.impl.LoginDaoImpl.java
public List<Map<String, Object>> getListPedidos(String login, Integer codigoPedido) { Query q = getSession().createSQLQuery( "select " + " pz.nom as nome, " + " pz.prix as preco, " + " s.descricao " + "from pedido p " + "inner join pedido_pizzas pp " + " on pp.id_pedido = p.id " + "inner join pizza pz " + " on pz.id = pp.id_pizza " + "inner join situacao s " + " on p.id_situacao = s.id " + "where " + " p.login = :login " + " and p.id = :codigo"); q.setString("login", login); q.setInteger("codigo", codigoPedido); q.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); return q.list(); }
From source file:com.portal.dao.DepartmentDAOImpl.java
@Override public void deleteDepartment(int id) throws Exception { try {//www . ja va 2 s . com Query query = sessionFactory.getCurrentSession().createQuery("delete from Department where id=:id"); query.setInteger("id", id); query.executeUpdate(); } catch (ConstraintViolationException ex) { throw new PortalException( "? . ???? ?."); } }
From source file:com.portal.dao.EmployeeDAOImpl.java
@Override public void deleteEmployee(int id) { Query query = sessionFactory.getCurrentSession().createQuery("delete from Employee where id=:id"); query.setInteger("id", id); query.executeUpdate();//ww w. jav a 2 s . c o m }
From source file:com.portal.dao.PositionDAOImpl.java
@Override public void deletePosition(int id) throws Exception { try {// w w w. j av a 2 s . c om Query query = sessionFactory.getCurrentSession().createQuery("delete from Position where id=:id"); query.setInteger("id", id); query.executeUpdate(); } catch (ConstraintViolationException ex) { throw new PortalException( "? ?. ? ? ? ?."); } }