use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project perun by CESNET.
the class UsersManagerImpl method getUsersByIds.
public List<User> getUsersByIds(PerunSession sess, List<Integer> usersIds) throws InternalErrorException {
// If usersIds is empty, we can immediatelly return empty results
if (usersIds.size() == 0) {
return new ArrayList<User>();
}
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("ids", usersIds);
try {
return namedParameterJdbcTemplate.query("select " + userMappingSelectQuery + " from users where users.id in ( :ids )", parameters, USER_MAPPER);
} catch (EmptyResultDataAccessException ex) {
return new ArrayList<User>();
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project perun by CESNET.
the class GroupsManagerImpl method getGroupsByIds.
public List<Group> getGroupsByIds(PerunSession sess, List<Integer> groupsIds) throws InternalErrorException {
// If groupsIds are empty, we can immediately return empty result
if (groupsIds.size() == 0) {
return new ArrayList<Group>();
}
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("ids", groupsIds);
try {
return this.namedParameterJdbcTemplate.query("select " + groupMappingSelectQuery + " from groups where groups.id in ( :ids )", parameters, GROUP_MAPPER);
} catch (EmptyResultDataAccessException ex) {
return new ArrayList<Group>();
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project perun by CESNET.
the class TaskResultDaoJdbc method getTaskResultsForDestinations.
public List<TaskResult> getTaskResultsForDestinations(List<String> destinationsNames) throws InternalErrorException {
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("destinations", destinationsNames);
try {
return getNamedParameterJdbcTemplate().query("select " + taskResultMappingSelectQuery + ", " + ServicesManagerImpl.destinationMappingSelectQuery + ", " + ServicesManagerImpl.serviceMappingSelectQuery + " from tasks_results left join destinations on tasks_results.destination_id = destinations.id" + " left join tasks on tasks.id = tasks_results.task_id " + " left join exec_services on exec_services.id = tasks.exec_service_id" + " left join services on services.id = exec_services.service_id where destinations.destination in ( :destinations )", parameters, TASKRESULT_ROWMAPPER);
} catch (RuntimeException e) {
throw new InternalErrorException(e);
}
}
use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project spring-framework by spring-projects.
the class SimpleJdbcCallTests method testAddInvoiceProcWithoutMetaDataUsingMapParamSource.
@Test
public void testAddInvoiceProcWithoutMetaDataUsingMapParamSource() throws Exception {
initializeAddInvoiceWithoutMetaData(false);
SimpleJdbcCall adder = new SimpleJdbcCall(dataSource).withProcedureName("add_invoice");
adder.declareParameters(new SqlParameter("amount", Types.INTEGER), new SqlParameter("custid", Types.INTEGER), new SqlOutParameter("newid", Types.INTEGER));
Number newId = adder.executeObject(Number.class, new MapSqlParameterSource().addValue("amount", 1103).addValue("custid", 3));
assertEquals(4, newId.intValue());
verifyAddInvoiceWithoutMetaData(false);
verify(connection, atLeastOnce()).close();
}
use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project spring-framework by spring-projects.
the class SimpleJdbcCallTests method testAddInvoiceProcWithMetaDataUsingMapParamSource.
@Test
public void testAddInvoiceProcWithMetaDataUsingMapParamSource() throws Exception {
initializeAddInvoiceWithMetaData(false);
SimpleJdbcCall adder = new SimpleJdbcCall(dataSource).withProcedureName("add_invoice");
Number newId = adder.executeObject(Number.class, new MapSqlParameterSource().addValue("amount", 1103).addValue("custid", 3));
assertEquals(4, newId.intValue());
verifyAddInvoiceWithMetaData(false);
verify(connection, atLeastOnce()).close();
}
Aggregations