use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.
the class StringBasedJdbcQuery method execute.
/*
* (non-Javadoc)
* @see org.springframework.data.repository.query.RepositoryQuery#execute(java.lang.Object[])
*/
@Override
public Object execute(Object[] objects) {
RelationalParameterAccessor accessor = new RelationalParametersParameterAccessor(getQueryMethod(), objects);
ResultProcessor processor = getQueryMethod().getResultProcessor().withDynamicProjection(accessor);
ResultProcessingConverter converter = new ResultProcessingConverter(processor, this.converter.getMappingContext(), this.converter.getEntityInstantiators());
RowMapper<Object> rowMapper = determineRowMapper(rowMapperFactory.create(resolveTypeToRead(processor)), converter, accessor.findDynamicProjection() != null);
JdbcQueryExecution<?> queryExecution = getQueryExecution(//
queryMethod, //
determineResultSetExtractor(rowMapper), rowMapper);
return queryExecution.execute(determineQuery(), this.bindParameters(accessor));
}
use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.
the class PartTreeJdbcQuery method execute.
/*
* (non-Javadoc)
* @see org.springframework.data.repository.query.RepositoryQuery#execute(java.lang.Object[])
*/
@Override
public Object execute(Object[] values) {
RelationalParametersParameterAccessor accessor = new RelationalParametersParameterAccessor(getQueryMethod(), values);
ResultProcessor processor = getQueryMethod().getResultProcessor().withDynamicProjection(accessor);
ParametrizedQuery query = createQuery(accessor, processor.getReturnedType());
JdbcQueryExecution<?> execution = getQueryExecution(processor, accessor);
return execution.execute(query.getQuery(), query.getParameterSource());
}
use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.
the class PartTreeJdbcQueryUnitTests method createsQueryToFindAllEntitiesByDateAttributeBefore.
// DATAJDBC-318
@Test
public void createsQueryToFindAllEntitiesByDateAttributeBefore() throws Exception {
JdbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthBefore", Date.class);
PartTreeJdbcQuery jdbcQuery = createQuery(queryMethod);
RelationalParametersParameterAccessor accessor = getAccessor(queryMethod, new Object[] { new Date() });
ParametrizedQuery query = jdbcQuery.createQuery(accessor, returnedType);
assertThat(query.getQuery()).isEqualTo(BASE_SELECT + " WHERE " + TABLE + ".\"DATE_OF_BIRTH\" < :date_of_birth");
}
use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.
the class PartTreeJdbcQueryUnitTests method wrapsLikeOperatorParameterWithPercentSymbolsForNotContainingQuery.
// DATAJDBC-318
@Test
public void wrapsLikeOperatorParameterWithPercentSymbolsForNotContainingQuery() throws Exception {
JdbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotContaining", String.class);
PartTreeJdbcQuery jdbcQuery = createQuery(queryMethod);
RelationalParametersParameterAccessor accessor = getAccessor(queryMethod, new Object[] { "oh" });
ParametrizedQuery query = jdbcQuery.createQuery(accessor, returnedType);
assertThat(query.getQuery()).isEqualTo(BASE_SELECT + " WHERE " + TABLE + ".\"FIRST_NAME\" NOT LIKE :first_name");
assertThat(query.getParameterSource().getValue("first_name")).isEqualTo("%oh%");
}
use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.
the class PartTreeJdbcQueryUnitTests method createsQueryToFindAllEntitiesByStringAttributeStartingWith.
// DATAJDBC-318
@Test
public void createsQueryToFindAllEntitiesByStringAttributeStartingWith() throws Exception {
JdbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameStartingWith", String.class);
PartTreeJdbcQuery jdbcQuery = createQuery(queryMethod);
RelationalParametersParameterAccessor accessor = getAccessor(queryMethod, new Object[] { "Jo" });
ParametrizedQuery query = jdbcQuery.createQuery(accessor, returnedType);
assertThat(query.getQuery()).isEqualTo(BASE_SELECT + " WHERE " + TABLE + ".\"FIRST_NAME\" LIKE :first_name");
}
Aggregations