use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.
the class PartTreeJdbcQueryUnitTests method createsQueryToFindAllEntitiesByIntegerAttributeGreaterThanEqual.
// DATAJDBC-318
@Test
public void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThanEqual() throws Exception {
JdbcQueryMethod queryMethod = getQueryMethod("findAllByAgeGreaterThanEqual", Integer.class);
PartTreeJdbcQuery jdbcQuery = createQuery(queryMethod);
RelationalParametersParameterAccessor accessor = getAccessor(queryMethod, new Object[] { 30 });
ParametrizedQuery query = jdbcQuery.createQuery(accessor, returnedType);
assertThat(query.getQuery()).isEqualTo(BASE_SELECT + " WHERE " + TABLE + ".\"AGE\" >= :age");
}
use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.
the class PartTreeJdbcQueryUnitTests method createsQueryToFindAllEntitiesByStringAttributeEndingWith.
// DATAJDBC-318
@Test
public void createsQueryToFindAllEntitiesByStringAttributeEndingWith() throws Exception {
JdbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameEndingWith", String.class);
PartTreeJdbcQuery jdbcQuery = createQuery(queryMethod);
RelationalParametersParameterAccessor accessor = getAccessor(queryMethod, new Object[] { "hn" });
ParametrizedQuery query = jdbcQuery.createQuery(accessor, returnedType);
assertThat(query.getQuery()).isEqualTo(BASE_SELECT + " WHERE " + TABLE + ".\"FIRST_NAME\" LIKE :first_name");
}
use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.
the class PartTreeJdbcQueryUnitTests method createsQueryByEmbeddedProperty.
// DATAJDBC-318
@Test
public void createsQueryByEmbeddedProperty() throws Exception {
JdbcQueryMethod queryMethod = getQueryMethod("findByAddressStreet", String.class);
PartTreeJdbcQuery jdbcQuery = createQuery(queryMethod);
RelationalParametersParameterAccessor accessor = getAccessor(queryMethod, new Object[] { "Hello" });
ParametrizedQuery query = jdbcQuery.createQuery(accessor, returnedType);
String expectedSql = BASE_SELECT + " WHERE " + TABLE + ".\"USER_STREET\" = :user_street";
assertThat(query.getQuery()).isEqualTo(expectedSql);
assertThat(query.getParameterSource().getValue("user_street")).isEqualTo("Hello");
}
use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.
the class PartTreeJdbcQueryUnitTests method createsQueryToFindFirstEntityByStringAttribute.
// DATAJDBC-318
@Test
public void createsQueryToFindFirstEntityByStringAttribute() throws Exception {
JdbcQueryMethod queryMethod = getQueryMethod("findFirstByFirstName", String.class);
PartTreeJdbcQuery jdbcQuery = createQuery(queryMethod);
RelationalParametersParameterAccessor accessor = getAccessor(queryMethod, new Object[] { "John" });
ParametrizedQuery query = jdbcQuery.createQuery(accessor, returnedType);
String expectedSql = BASE_SELECT + " WHERE " + TABLE + ".\"FIRST_NAME\" = :first_name LIMIT 1";
assertThat(query.getQuery()).isEqualTo(expectedSql);
}
use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.
the class PartTreeJdbcQueryUnitTests method appendsLikeOperatorParameterWithPercentSymbolForStartingWithQuery.
// DATAJDBC-318
@Test
public void appendsLikeOperatorParameterWithPercentSymbolForStartingWithQuery() 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");
assertThat(query.getParameterSource().getValue("first_name")).isEqualTo("Jo%");
}
Aggregations