Search in sources :

Example 16 with Condition

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

the class QueryMapperUnitTests method shouldMapSimpleCriteriaWithoutEntity.

// DATAJDBC-318
@Test
public void shouldMapSimpleCriteriaWithoutEntity() {
    Criteria criteria = Criteria.where("name").is("foo");
    Condition condition = mapper.getMappedObject(new MapSqlParameterSource(), criteria, Table.create("person"), null);
    assertThat(condition).hasToString("person.name = ?[:name]");
}
Also used : Condition(org.springframework.data.relational.core.sql.Condition) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Criteria(org.springframework.data.relational.core.query.Criteria) Test(org.junit.jupiter.api.Test)

Example 17 with Condition

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

the class QueryMapperUnitTests method shouldMapIsNotNull.

// DATAJDBC-318
@Test
public void shouldMapIsNotNull() {
    Criteria criteria = Criteria.where("name").isNotNull();
    Condition condition = map(criteria);
    assertThat(condition).hasToString("person.\"NAME\" IS NOT 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)

Example 18 with Condition

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

the class QueryMapperUnitTests method shouldMapIsNotIn.

// DATAJDBC-318
@Test
public void shouldMapIsNotIn() {
    Criteria criteria = Criteria.where("name").notIn("a", "b", "c");
    Condition condition = map(criteria);
    assertThat(condition).hasToString("person.\"NAME\" NOT IN (?[:name], ?[:name1], ?[:name2])");
}
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 19 with Condition

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

the class QueryMapperUnitTests method shouldMapSimpleCriteria.

// DATAJDBC-318
@Test
public void shouldMapSimpleCriteria() {
    Criteria criteria = Criteria.where("name").is("foo");
    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 20 with Condition

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

the class QueryMapperUnitTests method shouldMapIsLte.

// DATAJDBC-318
@Test
public void shouldMapIsLte() {
    Criteria criteria = Criteria.where("name").lessThanOrEquals("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)

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