Search in sources :

Example 1 with Condition

use of org.springframework.data.relational.core.sql.Condition in project spring-data-jdbc by spring-projects.

the class QueryMapperUnitTests method shouldMapIsGte.

// DATAJDBC-318
@Test
public void shouldMapIsGte() {
    Criteria criteria = Criteria.where("name").greaterThanOrEquals("a");
    Condition condition = map(criteria);
    assertThat(condition).hasToString("person.\"NAME\" >= ?[:name]");
}
Also used : Condition(org.springframework.data.relational.core.sql.Condition) Criteria(org.springframework.data.relational.core.query.Criteria) Test(org.junit.jupiter.api.Test)

Example 2 with Condition

use of org.springframework.data.relational.core.sql.Condition in project spring-data-jdbc by spring-projects.

the class QueryMapperUnitTests method shouldMapIsGt.

// DATAJDBC-318
@Test
public void shouldMapIsGt() {
    Criteria criteria = Criteria.where("name").greaterThan("a");
    Condition condition = map(criteria);
    assertThat(condition).hasToString("person.\"NAME\" > ?[:name]");
}
Also used : Condition(org.springframework.data.relational.core.sql.Condition) Criteria(org.springframework.data.relational.core.query.Criteria) Test(org.junit.jupiter.api.Test)

Example 3 with Condition

use of org.springframework.data.relational.core.sql.Condition in project spring-data-jdbc by spring-projects.

the class QueryMapperUnitTests method shouldMapFromConcat.

// DATAJDBC-560
@Test
public void shouldMapFromConcat() {
    Criteria criteria = Criteria.from(Criteria.where("name").is("Foo"), // 
    Criteria.where("name").is("Bar").or("age").lessThan(49));
    assertThat(criteria.isEmpty()).isFalse();
    Condition condition = map(criteria);
    assertThat(condition).hasToString("(person.\"NAME\" = ?[:name] AND (person.\"NAME\" = ?[:name1] OR person.age < ?[:age]))");
}
Also used : Condition(org.springframework.data.relational.core.sql.Condition) Criteria(org.springframework.data.relational.core.query.Criteria) Test(org.junit.jupiter.api.Test)

Example 4 with Condition

use of org.springframework.data.relational.core.sql.Condition in project spring-data-jdbc by spring-projects.

the class QueryMapperUnitTests method shouldConsiderColumnName.

// DATAJDBC-318
@Test
public void shouldConsiderColumnName() {
    Criteria criteria = Criteria.where("alternative").is("foo");
    Condition condition = map(criteria);
    assertThat(condition).hasToString("person.\"another_name\" = ?[:another_name]");
}
Also used : Condition(org.springframework.data.relational.core.sql.Condition) Criteria(org.springframework.data.relational.core.query.Criteria) Test(org.junit.jupiter.api.Test)

Example 5 with Condition

use of org.springframework.data.relational.core.sql.Condition in project spring-data-jdbc by spring-projects.

the class QueryMapperUnitTests method shouldMapSimpleNullableCriteria.

// DATAJDBC-318
@Test
public void shouldMapSimpleNullableCriteria() {
    Criteria criteria = Criteria.where("name").isNull();
    Condition condition = map(criteria);
    assertThat(condition).hasToString("person.\"NAME\" IS NULL");
}
Also used : Condition(org.springframework.data.relational.core.sql.Condition) Criteria(org.springframework.data.relational.core.query.Criteria) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)22 Criteria (org.springframework.data.relational.core.query.Criteria)22 Condition (org.springframework.data.relational.core.sql.Condition)22 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)1