Package com.mysema.query.types.expr

Examples of com.mysema.query.types.expr.BooleanExpression


        assertEquals(Arrays.asList("Robert", "John", "Barbara", "Anton"), desc);
    }

    @Test
    public void Paging() {
        BooleanExpression filter = user.middleName.eq("X");
        OrderSpecifier<?> order = user.firstName.asc();

        // limit
        List<String> limit = getFirstNames(query().where(filter).orderBy(order)
                .limit(2).list());
View Full Code Here


        assertEquals(Arrays.asList("Barbara", "John"), limitAndOffset);
    }

    @Test
    public void ListResults() {
        BooleanExpression filter = user.middleName.eq("X");
        SearchResults<User> users = query().where(filter).orderBy(
                user.firstName.asc()).limit(2).listResults();
        List<String> asc = getFirstNames(users.getResults());
        assertEquals(Arrays.asList("Anton", "Barbara"), asc);
        assertEquals(4, users.getTotal());
View Full Code Here

        }
    }
   
    @Test
    public void ScalarQueries() {
        BooleanExpression filter = product.name.startsWith("A");
       
        // count
        assertEquals(10l, sql().from(product).where(filter).count());

        // countDistinct
View Full Code Here

    @Test
    public void QueryElement() throws Exception{
        Query query1 = serializer.toQuery(author.like("Michael"), metadata);
        Query query2 = serializer.toQuery(text.like("Text"), metadata);

        BooleanExpression query = BooleanExpression.anyOf(
            new QueryElement(query1),
            new QueryElement(query2)
        );
        testQuery(query, "author:michael text:text", 1);
    }
View Full Code Here

            throw new UnsupportedOperationException("No primary keys available");
        }
        if (pk1.getLocalColumns().size() != pk2.getLocalColumns().size()) {
            throw new UnsupportedOperationException("Size mismatch for primary key columns");
        }
        BooleanExpression rv = null;
        for (int i = 0; i < pk1.getLocalColumns().size(); i++) {
            BooleanExpression pred = BooleanOperation.create(op, pk1.getLocalColumns().get(i), pk2.getLocalColumns().get(i));
            rv = rv != null ? rv.and(pred) : pred;
        }
        return rv;
    }
View Full Code Here

                        StringExpression str = (StringExpression)rv;
                        toVisit.add(str.toLowerCase());
                        toVisit.add(str.charAt(0));
                        toVisit.add(str.isEmpty());
                    } else if (rv instanceof BooleanExpression) {
                        BooleanExpression b = (BooleanExpression)rv;
                        toVisit.add(b.not());
                    }
                    toVisit.add((Expression<?>) rv);
                }
            }
        }
View Full Code Here

    @Test
    public void QueryElement() throws Exception{
        Query query1 = serializer.toQuery(author.like("Michael"), metadata);
        Query query2 = serializer.toQuery(text.like("Text"), metadata);

        BooleanExpression query = BooleanExpression.anyOf(
            new QueryElement(query1),
            new QueryElement(query2)
        );
        testQuery(query, "author:michael text:text", 1);
    }
View Full Code Here

    @Test
    @Ignore // isn't a valid JPQL query
    public void Subquery_UniqueResult() {
        QCat cat2 = new QCat("cat2");

        BooleanExpression exists = new JPASubQuery().from(cat2).where(cat2.eyecolor.isNotNull()).exists();
        assertNotNull(query().from(cat)
                .where(cat.breed.eq(0).not())
                .singleResult(new QCatSummary(cat.breed.count(), exists)));
    }
View Full Code Here

        assertNotNull(beanPath.instanceOf(BeanPathTest.class));
    }
   
    @Test
    public void InstanceOfAny() {
        BooleanExpression pred1 = beanPath.instanceOf(BeanPathTest.class).or(beanPath.instanceOf(SubClass.class));
        BooleanExpression pred2 = beanPath.instanceOfAny(BeanPathTest.class, SubClass.class);
        assertEquals(pred1, pred2);
        assertEquals("p.class = class com.mysema.query.types.path.BeanPathTest || " +
               "p.class = class com.mysema.query.types.path.BeanPathTest$SubClass", pred2.toString());
    }
View Full Code Here

   
    @Test
    public void test() {
        StringPath str1 = new StringPath("str1");
        StringPath str2 = new StringPath("str2");
        BooleanExpression pending = str1.eq("3").and(str2.eq("1"));
        BooleanExpression notNew = str1.ne("1").and(str2.in("2", "3"));      
        BooleanExpression whereClause = str1.eq("a").and(pending.or(notNew));
        String str = new SQLSerializer(Configuration.DEFAULT).handle(whereClause).toString();
        assertEquals("str1 = ? and (str1 = ? and str2 = ? or str1 != ? and str2 in (?, ?))", str);
    }
View Full Code Here

TOP

Related Classes of com.mysema.query.types.expr.BooleanExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.