Search in sources :

Example 21 with Criteria

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

Example 22 with Criteria

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

the class QueryMapperUnitTests method shouldMapAndOrCriteria.

// DATAJDBC-318
@Test
public void shouldMapAndOrCriteria() {
    Criteria criteria = // 
    Criteria.where("name").is("foo").and("name").isNotNull().or("bar").is(// 
    "baz").and("anotherOne").is("alternative");
    Condition condition = map(criteria);
    assertThat(condition).hasToString("person.\"NAME\" = ?[:name] AND person.\"NAME\" IS NOT NULL OR person.bar = ?[:bar] AND person.anotherOne = ?[:anotherOne]");
}
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 23 with Criteria

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

the class QueryMapperUnitTests method shouldMapIsNull.

// DATAJDBC-318
@Test
public void shouldMapIsNull() {
    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)

Example 24 with Criteria

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

the class QueryMapperUnitTests method shouldMapIsLt.

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

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

the class QueryMapperUnitTests method shouldMapAndCriteria.

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

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