Search in sources :

Example 21 with RelationalParametersParameterAccessor

use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.

the class PartTreeJdbcQueryUnitTests method createsQueryToFindAllEntitiesByStringAttributeNotLike.

// DATAJDBC-318
@Test
public void createsQueryToFindAllEntitiesByStringAttributeNotLike() throws Exception {
    JdbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotLike", 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\" NOT LIKE :first_name");
}
Also used : RelationalParametersParameterAccessor(org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor) Test(org.junit.jupiter.api.Test)

Example 22 with RelationalParametersParameterAccessor

use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.

the class PartTreeJdbcQueryUnitTests method createsQueryToFindAllEntitiesByIntegerAttributeLessThanEqual.

// DATAJDBC-318
@Test
public void createsQueryToFindAllEntitiesByIntegerAttributeLessThanEqual() throws Exception {
    JdbcQueryMethod queryMethod = getQueryMethod("findAllByAgeLessThanEqual", 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");
}
Also used : RelationalParametersParameterAccessor(org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor) Test(org.junit.jupiter.api.Test)

Example 23 with RelationalParametersParameterAccessor

use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.

the class PartTreeJdbcQueryUnitTests method createsQueryToFindAllEntitiesByIntegerAttributeGreaterThan.

// DATAJDBC-318
@Test
public void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThan() throws Exception {
    JdbcQueryMethod queryMethod = getQueryMethod("findAllByAgeGreaterThan", 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");
}
Also used : RelationalParametersParameterAccessor(org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor) Test(org.junit.jupiter.api.Test)

Example 24 with RelationalParametersParameterAccessor

use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.

the class PartTreeJdbcQueryUnitTests method createsQueryToFindAllEntitiesByIntegerAttributeIsNull.

// DATAJDBC-318
@Test
public void createsQueryToFindAllEntitiesByIntegerAttributeIsNull() throws Exception {
    JdbcQueryMethod queryMethod = getQueryMethod("findAllByAgeIsNull");
    PartTreeJdbcQuery jdbcQuery = createQuery(queryMethod);
    RelationalParametersParameterAccessor accessor = getAccessor(queryMethod, new Object[0]);
    ParametrizedQuery query = jdbcQuery.createQuery(accessor, returnedType);
    assertThat(query.getQuery()).isEqualTo(BASE_SELECT + " WHERE " + TABLE + ".\"AGE\" IS NULL");
}
Also used : RelationalParametersParameterAccessor(org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor) Test(org.junit.jupiter.api.Test)

Example 25 with RelationalParametersParameterAccessor

use of org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor in project spring-data-jdbc by spring-projects.

the class PartTreeJdbcQueryUnitTests method createsQueryWithLimitToFindEntitiesByStringAttribute.

// DATAJDBC-318
@Test
public void createsQueryWithLimitToFindEntitiesByStringAttribute() throws Exception {
    JdbcQueryMethod queryMethod = getQueryMethod("findTop3ByFirstName", 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 3";
    assertThat(query.getQuery()).isEqualTo(expectedSql);
}
Also used : RelationalParametersParameterAccessor(org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor) Test(org.junit.jupiter.api.Test)

Aggregations

RelationalParametersParameterAccessor (org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor)33 Test (org.junit.jupiter.api.Test)31 Date (java.util.Date)3 ResultProcessor (org.springframework.data.repository.query.ResultProcessor)2 RelationalParameterAccessor (org.springframework.data.relational.repository.query.RelationalParameterAccessor)1