@Test public void saveGroups() { dbGroupMember.cleanDb(); List<Integer> groups = new ArrayList<Integer>(); groups.add(1); groups.add(2); repo.saveGroups("paperone", groups); }
public Boolean saveGroups(final String username, final List<Integer> groups) { return execute(new SqlMapClientCallback<Boolean>() { @SuppressWarnings("unchecked") public Boolean doInSqlMapClient(SqlMapExecutor executor) { int ris = 0; try { executor.startBatch(); Iterator<Integer> iter = groups.iterator(); while (iter.hasNext()) { Map params = new HashMap(); params.put("username", username); params.put("id", iter.next()); executor.insert("insertGroupUser", params); } ris = executor.executeBatch(); } catch (SQLException e) { Logger log = LoggerFactory.getLogger(this.getClass()); StringBuffer sb = new StringBuffer("saveGroups failed \n").append("num groups batch:").append(groups.size()).append("\n").append(" username:").append(username).append("\n") .append(e.getNextException()); log.error(sb.toString()); } return ris > 0; } }); }
GroupRepositoryIbatis extends SqlMapClientTemplate implements GroupRepository { public Boolean saveGroups(final String username, final List<Integer> groups) { return execute(new SqlMapClientCallback<Boolean>() { @SuppressWarnings("unchecked") public Boolean doInSqlMapClient(SqlMapExecutor executor) { int ris = 0; try { executor.startBatch(); Iterator<Integer> iter = groups.iterator(); while (iter.hasNext()) { Map params = new HashMap(); params.put("username", username); params.put("id", iter.next()); executor.insert("insertGroupUser", params); } ris = executor.executeBatch(); } catch (SQLException e) { Logger log = LoggerFactory.getLogger(this.getClass()); StringBuffer sb = new StringBuffer("saveGroups failed \n").append("num groups batch:").append(groups.size()).append("\n").append(" username:").append(username).append("\n") .append(e.getNextException()); log.error(sb.toString()); } return ris > 0; } }); } }
GroupRepositoryIbatis extends SqlMapClientTemplate implements GroupRepository { public Boolean saveGroups(final String username, final List<Integer> groups) { return execute(new SqlMapClientCallback<Boolean>() { @SuppressWarnings("unchecked") public Boolean doInSqlMapClient(SqlMapExecutor executor) { int ris = 0; try { executor.startBatch(); Iterator<Integer> iter = groups.iterator(); while (iter.hasNext()) { Map params = new HashMap(); params.put("username", username); params.put("id", iter.next()); executor.insert("insertGroupUser", params); } ris = executor.executeBatch(); } catch (SQLException e) { Logger log = LoggerFactory.getLogger(this.getClass()); StringBuffer sb = new StringBuffer("saveGroups failed \n").append("num groups batch:").append(groups.size()).append("\n").append(" username:").append(username).append("\n") .append(e.getNextException()); log.error(sb.toString()); } return ris > 0; } }); }  }
GroupRepositoryIbatis extends SqlMapClientTemplate implements GroupRepository { public Boolean saveGroups(final String username, final List<Integer> groups) { return execute(new SqlMapClientCallback<Boolean>() { @SuppressWarnings("unchecked") public Boolean doInSqlMapClient(SqlMapExecutor executor) { int ris = 0; try { executor.startBatch(); Iterator<Integer> iter = groups.iterator(); while (iter.hasNext()) { Map params = new HashMap(); params.put("username", username); params.put("id", iter.next()); executor.insert("insertGroupUser", params); } ris = executor.executeBatch(); } catch (SQLException e) { Logger log = LoggerFactory.getLogger(this.getClass()); StringBuffer sb = new StringBuffer("saveGroups failed \n").append("num groups batch:").append(groups.size()).append("\n").append(" username:").append(username).append("\n") .append(e.getNextException()); log.error(sb.toString()); } return ris > 0; } }); }  @Autowired @Override void setSqlMapClient(@Qualifier("sqlMapClient") SqlMapClient sqlMapClient); @SuppressWarnings("unchecked") List<GroupDTO> getUserGroupsWithAutorities(String username); Boolean hasUsers(Integer id); @SuppressWarnings("unchecked") List<String> getGroupUsernames(Integer id); Boolean deleteUserGroups(String username); @SuppressWarnings("unchecked") List<GroupDTO> getFreeGroups(String username); GroupDTO getGroup(Integer id); @SuppressWarnings("unchecked") List<GroupDTO> getGroups(); Boolean saveGroups(final String username, final List<Integer> groups); @SuppressWarnings("unchecked") List<GroupDTO> getGroups(Pager pager); Integer getGroupsNumber(); @SuppressWarnings("unchecked") List<GroupDTO> getUserGroups(String username); Boolean removeGroup(Integer id); Boolean save(GroupDTO group); }
GroupRepositoryIbatis extends SqlMapClientTemplate implements GroupRepository { public Boolean saveGroups(final String username, final List<Integer> groups) { return execute(new SqlMapClientCallback<Boolean>() { @SuppressWarnings("unchecked") public Boolean doInSqlMapClient(SqlMapExecutor executor) { int ris = 0; try { executor.startBatch(); Iterator<Integer> iter = groups.iterator(); while (iter.hasNext()) { Map params = new HashMap(); params.put("username", username); params.put("id", iter.next()); executor.insert("insertGroupUser", params); } ris = executor.executeBatch(); } catch (SQLException e) { Logger log = LoggerFactory.getLogger(this.getClass()); StringBuffer sb = new StringBuffer("saveGroups failed \n").append("num groups batch:").append(groups.size()).append("\n").append(" username:").append(username).append("\n") .append(e.getNextException()); log.error(sb.toString()); } return ris > 0; } }); }  @Autowired @Override void setSqlMapClient(@Qualifier("sqlMapClient") SqlMapClient sqlMapClient); @SuppressWarnings("unchecked") List<GroupDTO> getUserGroupsWithAutorities(String username); Boolean hasUsers(Integer id); @SuppressWarnings("unchecked") List<String> getGroupUsernames(Integer id); Boolean deleteUserGroups(String username); @SuppressWarnings("unchecked") List<GroupDTO> getFreeGroups(String username); GroupDTO getGroup(Integer id); @SuppressWarnings("unchecked") List<GroupDTO> getGroups(); Boolean saveGroups(final String username, final List<Integer> groups); @SuppressWarnings("unchecked") List<GroupDTO> getGroups(Pager pager); Integer getGroupsNumber(); @SuppressWarnings("unchecked") List<GroupDTO> getUserGroups(String username); Boolean removeGroup(Integer id); Boolean save(GroupDTO group);  }