use of org.springframework.jdbc.core.RowMapper in project spring-integration by spring-projects.
the class StoredProcExecutorTests method testSetReturningResultSetRowMappersWithEmptyMap.
@Test
public void testSetReturningResultSetRowMappersWithEmptyMap() {
DataSource datasource = mock(DataSource.class);
StoredProcExecutor storedProcExecutor = new StoredProcExecutor(datasource);
Map<String, RowMapper<?>> rowmappers = new HashMap<String, RowMapper<?>>();
storedProcExecutor.setReturningResultSetRowMappers(rowmappers);
// Should Successfully finish
}
use of org.springframework.jdbc.core.RowMapper in project spring-integration by spring-projects.
the class StoredProcPollingChannelAdapterParserTests method testReturningResultSetRowMappersAreSet.
@SuppressWarnings("unchecked")
@Test
public void testReturningResultSetRowMappersAreSet() throws Exception {
setUp("storedProcPollingChannelAdapterParserTest.xml", getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(this.pollingAdapter);
Object source = accessor.getPropertyValue("source");
accessor = new DirectFieldAccessor(source);
source = accessor.getPropertyValue("executor");
accessor = new DirectFieldAccessor(source);
Object returningResultSetRowMappers = accessor.getPropertyValue("returningResultSetRowMappers");
assertNotNull(returningResultSetRowMappers);
assertTrue(returningResultSetRowMappers instanceof Map);
Map<String, RowMapper<?>> returningResultSetRowMappersAsMap = (Map<String, RowMapper<?>>) returningResultSetRowMappers;
assertTrue("The rowmapper was not set. Expected returningResultSetRowMappersAsMap.size() == 2", returningResultSetRowMappersAsMap.size() == 2);
Iterator<Entry<String, RowMapper<?>>> iterator = returningResultSetRowMappersAsMap.entrySet().iterator();
Entry<String, ?> mapEntry = iterator.next();
assertEquals("out", mapEntry.getKey());
assertTrue(mapEntry.getValue() instanceof PrimeMapper);
mapEntry = iterator.next();
assertEquals("out2", mapEntry.getKey());
assertTrue(mapEntry.getValue() instanceof SingleColumnRowMapper);
}
use of org.springframework.jdbc.core.RowMapper in project spring-integration by spring-projects.
the class StoredProcOutboundGatewayParserTests method testReturningResultSetRowMappersAreSet.
@SuppressWarnings("unchecked")
@Test
public void testReturningResultSetRowMappersAreSet() throws Exception {
setUp("storedProcOutboundGatewayParserTest.xml", getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(this.outboundGateway);
Object source = accessor.getPropertyValue("handler");
accessor = new DirectFieldAccessor(source);
source = accessor.getPropertyValue("executor");
accessor = new DirectFieldAccessor(source);
Object returningResultSetRowMappers = accessor.getPropertyValue("returningResultSetRowMappers");
assertNotNull(returningResultSetRowMappers);
assertTrue(returningResultSetRowMappers instanceof Map);
Map<String, RowMapper<?>> returningResultSetRowMappersAsMap = (Map<String, RowMapper<?>>) returningResultSetRowMappers;
assertTrue("The rowmapper was not set. Expected returningResultSetRowMappersAsMap.size() == 1", returningResultSetRowMappersAsMap.size() == 1);
Entry<String, ?> mapEntry1 = returningResultSetRowMappersAsMap.entrySet().iterator().next();
assertEquals("out", mapEntry1.getKey());
assertTrue(mapEntry1.getValue() instanceof PrimeMapper);
}
use of org.springframework.jdbc.core.RowMapper in project spring-integration by spring-projects.
the class StoredProcExecutor method createSimpleJdbcCall.
private SimpleJdbcCall createSimpleJdbcCall(String storedProcedureName) {
final SimpleJdbcCall simpleJdbcCall = new SimpleJdbcCall(this.dataSource);
if (this.isFunction) {
simpleJdbcCall.withFunctionName(storedProcedureName);
} else {
simpleJdbcCall.withProcedureName(storedProcedureName);
}
if (this.ignoreColumnMetaData) {
simpleJdbcCall.withoutProcedureColumnMetaDataAccess();
}
simpleJdbcCall.declareParameters(this.sqlParameters.toArray(new SqlParameter[this.sqlParameters.size()]));
if (!this.returningResultSetRowMappers.isEmpty()) {
for (Entry<String, RowMapper<?>> mapEntry : this.returningResultSetRowMappers.entrySet()) {
simpleJdbcCall.returningResultSet(mapEntry.getKey(), mapEntry.getValue());
}
}
if (this.returnValueRequired) {
simpleJdbcCall.withReturnValue();
}
simpleJdbcCall.getJdbcTemplate().setSkipUndeclaredResults(this.skipUndeclaredResults);
return simpleJdbcCall;
}
use of org.springframework.jdbc.core.RowMapper in project ovirt-engine by oVirt.
the class TagDaoImpl method getTagUserGroupByGroupIdAndByTagId.
@Override
public TagsUserGroupMap getTagUserGroupByGroupIdAndByTagId(Guid tag, Guid group) {
MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("group_id", group).addValue("tag_id", tag);
RowMapper<TagsUserGroupMap> mapper = (rs, rowNum) -> {
TagsUserGroupMap entity = new TagsUserGroupMap();
entity.setGroupId(getGuidDefaultEmpty(rs, "group_id"));
entity.setTagId(getGuidDefaultEmpty(rs, "tag_id"));
return entity;
};
return getCallsHandler().executeRead("GetTagUserGroupByGroupIdAndByTagId", mapper, parameterSource);
}
Aggregations