Java Code Examples for org.hibernate.SQLQuery#setInteger()
The following examples show how to use
org.hibernate.SQLQuery#setInteger() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SecurityDAO.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public boolean isLessonLearner(Long lessonId, Integer userId) { SQLQuery query = getSession().createSQLQuery(SecurityDAO.CHECK_LESSON_LEARNER); query.setLong("lessonId", lessonId); query.setInteger("user_id", userId); return !query.list().isEmpty(); }
Example 2
Source File: PolicyDAO.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public List<PolicyDTO> getPolicyDtosByUser(Integer userId) { final String LOAD_POLICIES_WITH_USER_CONSENTS = "SELECT policy.*, policyConsent.uid IS NOT NULL as isConsentedByUser, policyConsent.date_agreed_on as dateAgreedOn " + "FROM lams_policy AS policy " + "LEFT JOIN lams_policy_consent AS policyConsent ON policyConsent.policy_uid = policy.uid AND policyConsent.user_id = :userId " + "WHERE policy.policy_state_id=1"; SQLQuery query = getSession().createSQLQuery(LOAD_POLICIES_WITH_USER_CONSENTS); query.addEntity(Policy.class); query.addScalar("isConsentedByUser"); query.addScalar("dateAgreedOn"); query.setInteger("userId", userId); List<Object[]> resultQuery = query.list(); // this map keeps the insertion order LinkedList<PolicyDTO> policyDtos = new LinkedList<PolicyDTO>(); // make the result easier to process for (Object[] entry : resultQuery) { Policy policy = (Policy) entry[0]; PolicyDTO policyDto = new PolicyDTO(policy); boolean isConsentedByUser = ((Number) entry[1]).intValue() == 1; policyDto.setConsentedByUser(isConsentedByUser); Date dateAgreedOn = (Date) entry[2]; policyDto.setDateAgreedOn(dateAgreedOn); policyDtos.add(policyDto); } return policyDtos; }
Example 3
Source File: ForfeitDaoImpl.java From LibrarySystem with Apache License 2.0 | 5 votes |
@Override public List<ForfeitInfo> getForfeitByReader(Reader reader) { // TODO Auto-generated method stub String hql = "SELECT f.borrowId,f.forfeit,f.isPay,f.aid FROM forfeitinfo f,borrowinfo b where b.borrowId = f.borrowId and b.readerId =?"; List list = null; try{ Session session = this.getSession(); SQLQuery createSQLQuery = session.createSQLQuery(hql); createSQLQuery.setInteger(0, reader.getReaderId()); list = createSQLQuery.list(); if(list!=null){ List<ForfeitInfo> infos = new ArrayList<ForfeitInfo>(); for(int i = 0;i<list.size();i++){ Object[] objects = (Object[]) list.get(i); Integer borrowId = (Integer) objects[0]; Double forfeit = (Double) objects[1]; Integer isPay = (Integer) objects[2]; Integer aid = (Integer) objects[3]; Admin admin = new Admin(); admin.setAid(aid); BorrowInfo info = new BorrowInfo(); info.setBorrowId(borrowId); ForfeitInfo forfeitInfo = new ForfeitInfo(); forfeitInfo.setAdmin(admin); forfeitInfo.setBorrowId(borrowId); forfeitInfo.setForfeit(forfeit); forfeitInfo.setIsPay(isPay); infos.add(forfeitInfo); } return infos; } }catch (Throwable e) { e.printStackTrace(); throw new RuntimeException(e.getMessage()); } return null; }
Example 4
Source File: QuestionDaoImpl.java From DWSurvey with GNU Affero General Public License v3.0 | 5 votes |
/** * 更新orderbyId * 属性 belongId所有题目,只要大于等于orderById+1 * @param belongId * @param orderById */ private void quOrderByIdAdd1(String belongId,Integer orderById){ if(belongId!=null && !"".equals(belongId)){ String sql="update t_question set order_by_id=order_by_id+1 where belong_id=? and order_by_id>=?"; //更新排序号 SQLQuery query=this.getSession().createSQLQuery(sql); query.setString(0, belongId); query.setInteger(1, orderById); query.executeUpdate(); } }
Example 5
Source File: QuestionDaoImpl.java From DWSurvey with GNU Affero General Public License v3.0 | 5 votes |
public void quOrderByIdDel1(String belongId,Integer orderById){ if(belongId!=null && !"".equals(belongId)){ String sql="update t_question set order_by_id=order_by_id-1 where belong_id=? and order_by_id>=?"; //更新排序号 SQLQuery query=this.getSession().createSQLQuery(sql); query.setString(0, belongId); query.setInteger(1, orderById); query.executeUpdate(); } }
Example 6
Source File: QuRadioDaoImpl.java From DWSurvey with GNU Affero General Public License v3.0 | 5 votes |
public void quOrderByIdDel1(String quId,Integer orderById){ if(quId!=null && !"".equals(quId)){ String sql="update t_qu_radio set order_by_id=order_by_id-1 where qu_id=? and order_by_id>=?"; //更新排序号 SQLQuery query=this.getSession().createSQLQuery(sql); query.setString(0, quId); query.setInteger(1, orderById); query.executeUpdate(); } }