Package org.apache.cayenne.query

Examples of org.apache.cayenne.query.SelectQuery.andQualifier()


    @SuppressWarnings("unchecked")
    public List<Customer> getCustomers(String name, Date startDate) {
        SelectQuery query = new SelectQuery(Customer.class);

        if (StringUtils.isNotBlank(name)) {
            query.andQualifier(ExpressionFactory.likeIgnoreCaseExp(Customer.NAME_PROPERTY, "%" + name + "%"));
        }
        if (startDate != null) {
            query.andQualifier(ExpressionFactory.greaterOrEqualExp(Customer.DATE_JOINED_PROPERTY, startDate));
        }
View Full Code Here


        if (StringUtils.isNotBlank(name)) {
            query.andQualifier(ExpressionFactory.likeIgnoreCaseExp(Customer.NAME_PROPERTY, "%" + name + "%"));
        }
        if (startDate != null) {
            query.andQualifier(ExpressionFactory.greaterOrEqualExp(Customer.DATE_JOINED_PROPERTY, startDate));
        }

        query.addOrdering(Customer.NAME_PROPERTY, true);
        query.addOrdering(Customer.DATE_JOINED_PROPERTY, true);
View Full Code Here

    @SuppressWarnings("unchecked")
    public List<Customer> getCustomerNamesLike(String name) {
        SelectQuery query = new SelectQuery(Customer.class);

        query.andQualifier(ExpressionFactory.likeIgnoreCaseExp(Customer.NAME_PROPERTY, "%" + name + "%"));

        query.addOrdering(Customer.NAME_PROPERTY, true);

        query.setFetchLimit(10);
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public Customer findCustomerByName(String name) {
        SelectQuery query = new SelectQuery(Customer.class);
        query.andQualifier(ExpressionFactory.matchExp(Customer.NAME_PROPERTY,name));

        List list = performQuery(query);

        if (!list.isEmpty()) {
            return (Customer) list.get(0);
View Full Code Here

                        "INSERT INTO MT_TABLE1 (TABLE1_ID, GLOBAL_ATTRIBUTE1, SERVER_ATTRIBUTE1) VALUES (3, 'z', 'MM')"));

        CayenneContext context = createClientContext();

        SelectQuery query = new SelectQuery(ClientMtTable1.class);
        query.andQualifier(ExpressionFactory.likeExp(
                ClientMtTable1.SERVER_ATTRIBUTE1_PROPERTY,
                "X%"));
        List<ClientMtTable1> objects = context.performQuery(query);

        assertEquals(2, objects.size());
View Full Code Here

    public void testAliasPathSplits_SinglePath() throws Exception {
        createTwoArtistsTwoPaintingsDataSet();

        SelectQuery query = new SelectQuery(Artist.class);
        query.andQualifier(ExpressionFactory.matchExp("p.paintingTitle", "X"));

        query.aliasPathSplits("paintingArray", "p");

        List<Artist> artists = context.performQuery(query);
        assertEquals(1, artists.size());
View Full Code Here

    public void testAliasPathSplits_SplitJoin() throws Exception {
        createTwoArtistsThreePaintingsDataSet();

        SelectQuery query = new SelectQuery(Artist.class);
        query.andQualifier(ExpressionFactory.matchExp("p1.paintingTitle", "X"));
        query.andQualifier(ExpressionFactory.matchExp("p2.paintingTitle", "Y"));

        query.aliasPathSplits("paintingArray", "p1", "p2");

        List<Artist> artists = context.performQuery(query);
View Full Code Here

    public void testAliasPathSplits_SplitJoin() throws Exception {
        createTwoArtistsThreePaintingsDataSet();

        SelectQuery query = new SelectQuery(Artist.class);
        query.andQualifier(ExpressionFactory.matchExp("p1.paintingTitle", "X"));
        query.andQualifier(ExpressionFactory.matchExp("p2.paintingTitle", "Y"));

        query.aliasPathSplits("paintingArray", "p1", "p2");

        List<Artist> artists = context.performQuery(query);
        assertEquals(1, artists.size());
View Full Code Here

    public void testPrefetch_ToOne_DbPath() throws Exception {
        createTwoArtistsAndTwoPaintingsDataSet();

        SelectQuery q = new SelectQuery(Painting.class);
        q.addPrefetch(Painting.TO_ARTIST_PROPERTY);
        q.andQualifier(ExpressionFactory.matchDbExp("toArtist.ARTIST_NAME", "artist2"));

        List<Painting> results = context.performQuery(q);

        assertEquals(1, results.size());
    }
View Full Code Here

    public void testPrefetch_ToOne_ObjPath() throws Exception {
        createTwoArtistsAndTwoPaintingsDataSet();

        SelectQuery q = new SelectQuery(Painting.class);
        q.addPrefetch(Painting.TO_ARTIST_PROPERTY);
        q.andQualifier(ExpressionFactory.matchExp("toArtist.artistName", "artist2"));

        List<Painting> results = context.performQuery(q);
        assertEquals(1, results.size());
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.