Search in sources :

Example 16 with Predicate

use of com.querydsl.core.types.Predicate in project querydsl by querydsl.

the class DocumentTest method test1.

@Test
public void test1() {
    Predicate crit = qDoc.id.eq(3L);
    List<Document> expResult = CollQueryFactory.from(qDoc, doc1, doc2, doc3).where(crit).fetch();
    //ok
    assertTrue(expResult.contains(doc3));
}
Also used : Predicate(com.querydsl.core.types.Predicate) Test(org.junit.Test)

Example 17 with Predicate

use of com.querydsl.core.types.Predicate in project querydsl by querydsl.

the class DocumentTest method test2.

@Test
public void test2() {
    Predicate crit = qDoc.meshThesaurusTerms.any().eq("x");
    List<Document> expResult = CollQueryFactory.from(qDoc, doc1, doc2, doc3).where(crit).fetch();
    //ok
    assertTrue(expResult.contains(doc1));
}
Also used : Predicate(com.querydsl.core.types.Predicate) Test(org.junit.Test)

Example 18 with Predicate

use of com.querydsl.core.types.Predicate in project querydsl by querydsl.

the class DocumentTest method test3.

@Test
public void test3() {
    Predicate crit = qDoc.meshThesaurusTerms.any().eq("x").or(qDoc.id.eq(3L));
    List<Document> expResult = CollQueryFactory.from(qDoc, doc1, doc2, doc3).where(crit).fetch();
    assertTrue(expResult.contains(doc1));
    //fails, expResult contains only doc1, but should contain doc1 and doc3!
    assertTrue(expResult.contains(doc3));
}
Also used : Predicate(com.querydsl.core.types.Predicate) Test(org.junit.Test)

Example 19 with Predicate

use of com.querydsl.core.types.Predicate in project querydsl by querydsl.

the class JPACollectionAnyVisitorTest method nested_any_booleanOperation.

@Test
public void nested_any_booleanOperation() {
    QCompany company = QCompany.company;
    Predicate predicate = company.departments.any().employees.any().firstName.eq("Bob");
    assertEquals("exists (select 1\n" + "from company.departments as company_departments_0\n" + "  inner join company_departments_0.employees as company_departments_0_employees_1\n" + "where company_departments_0_employees_1.firstName = ?1)", serialize(predicate));
}
Also used : QCompany(com.querydsl.jpa.domain.QCompany) Predicate(com.querydsl.core.types.Predicate) Test(org.junit.Test)

Example 20 with Predicate

use of com.querydsl.core.types.Predicate in project querydsl by querydsl.

the class JPACollectionAnyVisitorTest method simple_booleanOperation_longPath.

@Test
public void simple_booleanOperation_longPath() {
    Predicate predicate = cat.kittens.any().kittens.any().name.eq("Ruth123");
    assertEquals("exists (select 1\n" + "from cat.kittens as cat_kittens_0\n" + "  inner join cat_kittens_0.kittens as cat_kittens_0_kittens_1\n" + "where cat_kittens_0_kittens_1.name = ?1)", serialize(predicate));
}
Also used : Predicate(com.querydsl.core.types.Predicate) Test(org.junit.Test)

Aggregations

Predicate (com.querydsl.core.types.Predicate)22 Test (org.junit.Test)20 QCat (com.querydsl.core.domain.QCat)1 Context (com.querydsl.core.support.Context)1 StringPath (com.querydsl.core.types.dsl.StringPath)1 QCompany (com.querydsl.jpa.domain.QCompany)1 QDomesticCat (com.querydsl.jpa.domain.QDomesticCat)1 QEmployee (com.querydsl.jpa.domain.QEmployee)1