Search in sources :

Example 26 with RelationalParametersParameterAccessor

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");
}
Also used : RelationalParametersParameterAccessor(org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor) Test(org.junit.jupiter.api.Test)

Example 27 with RelationalParametersParameterAccessor

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");
}
Also used : RelationalParametersParameterAccessor(org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor) Test(org.junit.jupiter.api.Test)

Example 28 with RelationalParametersParameterAccessor

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");
}
Also used : RelationalParametersParameterAccessor(org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor) Test(org.junit.jupiter.api.Test)

Example 29 with RelationalParametersParameterAccessor

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);
}
Also used : RelationalParametersParameterAccessor(org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor) Test(org.junit.jupiter.api.Test)

Example 30 with RelationalParametersParameterAccessor

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%");
}
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