List of usage examples for org.hibernate Query setInteger
@Deprecated @SuppressWarnings("unchecked") default Query<R> setInteger(String name, int val)
From source file:com.juzhituan.dao.impl.EmployerDaoHibernateImpl.java
@Override public void updateEmployer(final Integer employerId, final String cellphone, final String email) { getHibernateTemplate().execute(new HibernateCallback<Employer>() { @Override// ww w. ja va 2s . c om public Employer doInHibernate(Session session) throws HibernateException { String hql = "update Employer set cellphone=:cellphone,email=:email where employerId=:employerId"; Query query = session.createQuery(hql); query.setInteger("employerId", employerId); query.setString("cellphone", cellphone); query.setString("email", email); query.executeUpdate(); return null; } }); }
From source file:com.juzhituan.dao.impl.EmployerDaoHibernateImpl.java
@Override public void updateEmployer(final Integer employerId, final String password) { getHibernateTemplate().execute(new HibernateCallback<Employer>() { @Override//from w ww. j a v a 2 s . c o m public Employer doInHibernate(Session session) throws HibernateException { String hql = "update Employer set password=:password where employerId=:employerId"; Query query = session.createQuery(hql); query.setInteger("employerId", employerId); query.setString("password", password); query.executeUpdate(); return null; } }); }
From source file:com.kg.testjsfa8h4.dao.Form1Dao.java
public Form1 getForm1ById(int idForm1) { Form1 form1 = null;//from w w w . j a va 2 s. c om Transaction trns = null; Session session = HibernateUtil.getSessionFactory().openSession(); try { trns = session.beginTransaction(); String queryString = "from Form1 where id = :idToFind"; Query query = session.createQuery(queryString); query.setInteger("idToFind", idForm1); form1 = (Form1) query.uniqueResult(); } catch (Exception e) { e.printStackTrace(); } finally { session.flush(); session.close(); } return form1; }
From source file:com.knowbout.epg.entities.Credit.java
License:Apache License
public static Credit selectByValues(CreditType type, String firstName, String lastName, String roleDescription) { Session session = HibernateUtil.currentSession(); Query query = session.getNamedQuery("Credit.getByValues"); query.setInteger("type", type.ordinal()); query.setString("firstName", firstName); query.setString("lastName", lastName); query.setString("roleDescription", roleDescription); return (Credit) query.uniqueResult(); }
From source file:com.leapfrog.springFramework.DAO.Impl.AnswerDAOImpl.java
@Override public List<Answer> getAnswers(int q_id) { try {/*from www . ja v a 2s . c o m*/ session = sessionFactory.openSession(); trans = session.beginTransaction(); Query query = session.createQuery("SELECT a FROM Answer a WHERE a.question.questionId=:id"); query.setInteger("id", q_id); List<Answer> list = query.list(); if (list != null) { return list; } } catch (Exception ex) { System.out.println("Message: " + ex.getMessage()); } finally { session.close(); } return null; }
From source file:com.leapfrog.springFramework.DAO.Impl.QuestionDAOImpl.java
@Override public List<Question> getByUserId(int id) { try {//from w w w . java2s. c o m session = sessionFactory.openSession(); trans = session.beginTransaction(); Query query = session.createQuery("SELECT q FROM Question q WHERE q.user.userId=:id"); query.setInteger("id", id); List<Question> list = query.list(); if (list != null) { return list; } } catch (Exception ex) { System.out.println("Message: " + ex.getMessage()); } finally { session.close(); } return null; }
From source file:com.liteoc.dao.hibernate.SCDItemMetadataDao.java
License:LGPL
@SuppressWarnings("unchecked") public ArrayList<SCDItemMetadataBean> findAllBySectionId(Integer sectionId) { String query = "select scd.* from scd_item_metadata scd where scd.scd_item_form_metadata_id in (" + "select ifm.item_form_metadata_id from item_form_metadata ifm where ifm.section_id = :sectionId)"; org.hibernate.Query q = this.getCurrentSession().createSQLQuery(query).addEntity(this.domainClass()); q.setInteger("sectionId", sectionId); return (ArrayList<SCDItemMetadataBean>) q.list(); }
From source file:com.liteoc.dao.hibernate.SCDItemMetadataDao.java
License:LGPL
@SuppressWarnings("unchecked") public List<Integer> findAllSCDItemFormMetadataIdsBySectionId(Integer sectionId) { String query = "select scd.scd_item_form_metadata_id from scd_item_metadata scd where scd.scd_item_form_metadata_id in (" + "select ifm.item_form_metadata_id from item_form_metadata ifm where ifm.section_id = :sectionId)"; org.hibernate.Query q = this.getCurrentSession().createSQLQuery(query); q.setInteger("sectionId", sectionId); return q.list(); }
From source file:com.liusoft.dlog4j.dao.BBSForumDAO.java
License:Open Source License
/** * //from w w w .j a va 2 s . co m * * @param obj * @param pos * @param up * @throws CapacityExceedException */ public static void createForum(ForumBean obj, int pos, boolean up) throws CapacityExceedException { Session ssn = getSession(); int order_value = 1; if (pos > 0) { ForumBean friend = (ForumBean) ssn.get(ForumBean.class, new Integer(pos)); order_value = friend.getSortOrder(); } obj.setSortOrder(order_value - (up ? 1 : 0)); try { beginTransaction(); ssn.save(obj); // Query q = ssn.getNamedQuery("LIST_FORUMS"); q.setInteger(0, obj.getSite().getId()); List links = q.list(); if (links.size() >= ConfigDAO.getMaxCatalogCount(obj.getSite().getId())) throw new CapacityExceedException(links.size()); if (links.size() > 1) { for (int i = 0; i < links.size(); i++) { Orderable lb = (Orderable) links.get(i); executeNamedUpdate("UPDATE_FORUM_ORDER", i + 1, lb.getId()); } } commit(); } catch (HibernateException e) { rollback(); throw e; } }
From source file:com.liusoft.dlog4j.dao.BBSTopicDAO.java
License:Open Source License
/** * /*from w w w .j av a 2s .co m*/ * @param site * @param fbean * @return */ public static int getEliteCount(SiteBean site, ForumBean fbean) { StringBuffer hql = new StringBuffer("SELECT COUNT(*) FROM TopicBean AS t WHERE t.status=:status"); if (site != null) hql.append(" AND t.site.id=:site"); if (fbean != null) hql.append(" AND t.forum.id=:forum"); hql.append(" AND (t.type=:elite OR t.type=:top_elite)"); Session ssn = getSession(); Query q = ssn.createQuery(hql.toString()); q.setInteger("status", TopicBean.STATUS_NORMAL); q.setInteger("elite", TopicBean.INFO_TYPE_ELITE); q.setInteger("top_elite", TopicBean.INFO_TYPE_TOP_ELITE); if (site != null) q.setInteger("site", site.getId()); if (fbean != null) q.setInteger("forum", fbean.getId()); return ((Number) q.uniqueResult()).intValue(); }