use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.
the class PartTreeJdbcQueryUnitTests method createsQueryToFindAllEntitiesByIntegerAttributeWithDescendingOrderingByStringAttribute.
// DATAJDBC-318
@Test
public void createsQueryToFindAllEntitiesByIntegerAttributeWithDescendingOrderingByStringAttribute() throws Exception {
JdbcQueryMethod queryMethod = getQueryMethod("findAllByAgeOrderByLastNameDesc", Integer.class);
PartTreeJdbcQuery jdbcQuery = createQuery(queryMethod);
RelationalParametersParameterAccessor accessor = getAccessor(queryMethod, new Object[] { 123 });
ParametrizedQuery query = jdbcQuery.createQuery(accessor, returnedType);
assertThat(query.getQuery()).isEqualTo(BASE_SELECT + " WHERE " + TABLE + ".\"AGE\" = :age ORDER BY \"users\".\"LAST_NAME\" DESC");
}
use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.
the class PartTreeJdbcQueryUnitTests method createsQueryToFindAllEntitiesByDateAttributeAfter.
// DATAJDBC-318
@Test
public void createsQueryToFindAllEntitiesByDateAttributeAfter() throws Exception {
JdbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthAfter", 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 createsQueryToFindAllEntitiesByDateAttributeBetween.
// DATAJDBC-318
@Test
public void createsQueryToFindAllEntitiesByDateAttributeBetween() throws Exception {
JdbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthBetween", Date.class, Date.class);
PartTreeJdbcQuery jdbcQuery = createQuery(queryMethod);
Date from = new Date();
Date to = new Date();
RelationalParametersParameterAccessor accessor = getAccessor(queryMethod, new Object[] { from, to });
ParametrizedQuery query = jdbcQuery.createQuery(accessor, returnedType);
assertSoftly(softly -> {
softly.assertThat(query.getQuery()).isEqualTo(BASE_SELECT + " WHERE " + TABLE + ".\"DATE_OF_BIRTH\" BETWEEN :date_of_birth AND :date_of_birth1");
softly.assertThat(query.getParameterSource().getValue("date_of_birth")).isEqualTo(from);
softly.assertThat(query.getParameterSource().getValue("date_of_birth1")).isEqualTo(to);
});
}
use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.
the class PartTreeJdbcQueryUnitTests method createsQueryToFindAllEntitiesByStringAttributeLike.
// DATAJDBC-318
@Test
public void createsQueryToFindAllEntitiesByStringAttributeLike() throws Exception {
JdbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameLike", String.class);
PartTreeJdbcQuery jdbcQuery = createQuery(queryMethod);
RelationalParametersParameterAccessor accessor = getAccessor(queryMethod, new Object[] { "%John%" });
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 createsQueryToFindAllEntitiesByStringAttributeNotContaining.
// DATAJDBC-318
@Test
public void createsQueryToFindAllEntitiesByStringAttributeNotContaining() 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");
}
Aggregations