Search in sources :

Example 36 with Criteria

use of org.springframework.data.relational.core.query.Criteria 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 37 with Criteria

use of org.springframework.data.relational.core.query.Criteria 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 38 with Criteria

use of org.springframework.data.relational.core.query.Criteria 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)

Example 39 with Criteria

use of org.springframework.data.relational.core.query.Criteria in project spring-data-jdbc by spring-projects.

the class QueryMapperUnitTests method shouldMapOrCriteria.

// DATAJDBC-318
@Test
public void shouldMapOrCriteria() {
    Criteria criteria = Criteria.where("name").is("foo").or("bar").is("baz");
    Condition condition = map(criteria);
    assertThat(condition).hasToString("person.\"NAME\" = ?[:name] OR person.bar = ?[:bar]");
}
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 40 with Criteria

use of org.springframework.data.relational.core.query.Criteria in project spring-data-jdbc by spring-projects.

the class QueryMapperUnitTests method shouldNotMapEmptyCriteria.

// DATAJDBC-318
@Test
public void shouldNotMapEmptyCriteria() {
    Criteria criteria = Criteria.empty();
    assertThatIllegalArgumentException().isThrownBy(() -> map(criteria));
}
Also used : Criteria(org.springframework.data.relational.core.query.Criteria) Test(org.junit.jupiter.api.Test)

Aggregations

Criteria (org.springframework.data.relational.core.query.Criteria)50 Test (org.junit.jupiter.api.Test)49 Condition (org.springframework.data.relational.core.sql.Condition)22 QueryMethod (org.springframework.data.repository.query.QueryMethod)2 Part (org.springframework.data.repository.query.parser.Part)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Example (org.springframework.data.domain.Example)1 ExampleMatcher (org.springframework.data.domain.ExampleMatcher)1 PersistentPropertyAccessor (org.springframework.data.mapping.PersistentPropertyAccessor)1 PropertyHandler (org.springframework.data.mapping.PropertyHandler)1 MappingContext (org.springframework.data.mapping.context.MappingContext)1 RelationalPersistentEntity (org.springframework.data.relational.core.mapping.RelationalPersistentEntity)1 RelationalPersistentProperty (org.springframework.data.relational.core.mapping.RelationalPersistentProperty)1 Query (org.springframework.data.relational.core.query.Query)1 ExampleMatcherAccessor (org.springframework.data.support.ExampleMatcherAccessor)1 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)1 Assert (org.springframework.util.Assert)1