List of usage examples for org.apache.ibatis.session SqlSession selectList
<E> List<E> selectList(String statement, Object parameter, RowBounds rowBounds);
From source file:org.sonar.core.permission.PermissionTemplateDao.java
License:Open Source License
/** * @return a paginated list of users.//from www .j a v a2 s. c o m */ public List<UserWithPermissionDto> selectUsers(PermissionQuery query, Long templateId, int offset, int limit) { SqlSession session = myBatis.openSession(false); try { Map<String, Object> params = newHashMap(); params.put(QUERY_PARAMETER, query); params.put(TEMPLATE_ID_PARAMETER, templateId); return session.selectList("org.sonar.core.permission.PermissionTemplateMapper.selectUsers", params, new RowBounds(offset, limit)); } finally { MyBatis.closeQuietly(session); } }
From source file:org.sonar.core.qualitygate.db.ProjectQgateAssociationDao.java
License:Open Source License
public List<ProjectQgateAssociationDto> selectProjects(ProjectQgateAssociationQuery query, Long gateId, int offset, int limit) { SqlSession session = mybatis.openSession(false); try {//from ww w . j av a2s.co m Map<String, Object> params = ImmutableMap.of("query", query, "gateId", gateId.toString()); return session.selectList("org.sonar.core.qualitygate.db.ProjectQgateAssociationMapper.selectProjects", params, new RowBounds(offset, limit)); } finally { MyBatis.closeQuietly(session); } }
From source file:org.sonar.core.user.GroupMembershipDao.java
License:Open Source License
public List<GroupMembershipDto> selectGroups(GroupMembershipQuery query, Long userId, int offset, int limit) { SqlSession session = mybatis.openSession(false); try {//from ww w. j a va 2 s . c o m Map<String, Object> params = ImmutableMap.of("query", query, "userId", userId); return session.selectList("org.sonar.core.user.GroupMembershipMapper.selectGroups", params, new RowBounds(offset, limit)); } finally { MyBatis.closeQuietly(session); } }
From source file:webim.dao.ibatis.WebimHistoryDao.java
License:Apache License
/** * ?with?MySQL:<br>/*from w w w . j a va2s . com*/ * * <pre> * if (type == "chat") * { * * "SELECT * FROM webim_Histories WHERE `type` = 'chat' * AND ((`to`=%s AND `from`=%s AND `fromdel` != 1) * OR (`send` = 1 AND `from`=%s AND `to`=%s AND `todel` != 1)) * ORDER BY timestamp DESC LIMIT %d", $with, $uid, $with, $uid, $limit ); * * } * else * { * * "SELECT * FROM webim_histories * WHERE `to`=%s AND `type`='grpchat' AND send = 1 * ORDER BY timestamp DESC LIMIT %d", , $with, $limit); * * } * </pre> * * @param uid * ?id * @param with * id????long * @param type * chat | grpchat * * @param limit * ? * @return ? */ public List<WebimHistory> getHistories(String uid, String with, String type, int limit) { List<WebimHistory> histories = null; Map<String, String> params = new HashMap<String, String>(); //with -> to params.put("to", with); //uid -> from params.put("from", uid); RowBounds rb = new RowBounds(0, limit); SqlSession session = sessionFactory.openSession(); try { if (type.equals("chat")) { histories = session.selectList("HistoryMapper.selectChat", params, rb); } else if (type.equals("grpchat")) { histories = session.selectList("HistoryMapper.selectGrpChat", params, rb); } else { } } catch (Exception e) { e.printStackTrace(); } finally { session.close(); } if (histories == null) histories = new ArrayList<WebimHistory>(); Collections.reverse(histories); return histories; }
From source file:webim.dao.ibatis.WebimHistoryDao.java
License:Apache License
/** * ??MySQL:<br>//from w w w . j a v a 2 s . co m * * "SELECT * FROM webim_histories WHERE `to` = ? and send != 1 ORDER BY timestamp DESC LIMIT %d" * , limit; * * @param uid * uid * @return ? */ public List<WebimHistory> getOfflineHistories(String uid, int limit) { List<WebimHistory> histories = null; SqlSession session = sessionFactory.openSession(); try { histories = session.selectList("HistoryMapper.selectOffline", uid, new RowBounds(0, limit)); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); } if (histories == null) histories = new ArrayList<WebimHistory>(); Collections.reverse(histories); return histories; }