Package com.mysema.query.types

Examples of com.mysema.query.types.Predicate


    }

    @Test
    public void Simple_BooleanOperation_ElementCollection() {
        QEmployee employee = QEmployee.employee;
        Predicate predicate = employee.jobFunctions.any().eq(JobFunction.CODER);
        assertMatches("exists \\(select 1\n" +
          "from Employee employee.*\n" +
          "  inner join employee.*.jobFunctions as employee_jobFunctions.*\n" +
          "where employee.* = employee and employee_jobFunctions.* = \\?1\\)", serialize(predicate));
    }
View Full Code Here


          "where employee.* = employee and employee_jobFunctions.* = \\?1\\)", serialize(predicate));
    }

    @Test
    public void Simple_StringOperation() {
        Predicate predicate = cat.kittens.any().name.substring(1).eq("uth123");
        assertMatches("exists \\(select 1\n"+
                "from cat.kittens as cat_kittens.*\n" +
                "where substring\\(cat_kittens.*\\.name,2\\) = \\?1\\)", serialize(predicate));
    }
View Full Code Here

                "where substring\\(cat_kittens.*\\.name,2\\) = \\?1\\)", serialize(predicate));
    }

    @Test
    public void And_Operation() {
        Predicate predicate = cat.kittens.any().name.eq("Ruth123").and(cat.kittens.any().bodyWeight.gt(10.0));
        assertMatches("exists \\(select 1\n"+
                "from cat.kittens as cat_kittens.*\n" +
                "where cat_kittens.*\\.name = \\?1\\) and exists \\(select 1\n" +
                "from cat.kittens as cat_kittens.*\n" +
                "where cat_kittens.*\\.bodyWeight > \\?2\\)", serialize(predicate));
View Full Code Here

//        QDog anyDog = QPerson.person.animals.any().as(QDog.class);
//        query.where(anyDog.gender.eq("M"));
//        List<Person> foundOwners = query.list(QPerson.person);

        QDomesticCat anyCat = QCat.cat.kittens.any().as(QDomesticCat.class);
        Predicate predicate = anyCat.name.eq("X");

        assertMatches("exists \\(select 1\n" +
            "from cat.kittens as cat_kittens.*\n" +
            "where cat_kittens.*\\.name = \\?1\\)", serialize(predicate));
    }
View Full Code Here

            }           
            context.add(c);
        }
        if (context.replace) {            
            if (expr.getType().equals(Boolean.class)) {
                Predicate predicate = new PredicateTemplate(expr.getTemplate(), args);
                return !context.paths.isEmpty() ? exists(context, predicate) : predicate;          
            } else {
                return new TemplateExpressionImpl(expr.getType(), expr.getTemplate(), ImmutableList.copyOf(args));   
            }   
        } else {
View Full Code Here

            args[i] = expr.getArg(i).accept(this, c);
            context.add(c);
        }
        if (context.replace) {           
            if (expr.getType().equals(Boolean.class)) {
                Predicate predicate = new PredicateOperation((Operator)expr.getOperator(), ImmutableList.copyOf(args));
                return !context.paths.isEmpty() ? exists(context, predicate) : predicate;          
            } else {
                return new OperationImpl(expr.getType(), expr.getOperator(), ImmutableList.copyOf(args));   
            }   
        } else {
View Full Code Here

    @Override
    protected Predicate normalize(Predicate predicate, boolean where) {
        predicate = (Predicate)ExpressionUtils.extract(predicate);
        if (predicate != null) {
            Context context = new Context();
            Predicate transformed = (Predicate) predicate.accept(CollectionAnyVisitor.DEFAULT, context);
            for (int i = 0; i < context.paths.size(); i++) {
                leftJoin(
                    (Path)context.paths.get(i).getMetadata().getParent(),
                    (Path)context.replacements.get(i));
                on(ANY);
View Full Code Here

            }
            context.add(c);
        }
        if (context.replace) {
            if (expr.getType().equals(Boolean.class)) {
                Predicate predicate = BooleanTemplate.create(expr.getTemplate(), args);
                return !context.paths.isEmpty() ? exists(context, predicate) : predicate;
            } else {
                return TemplateExpressionImpl.create(expr.getType(), expr.getTemplate(), args);
            }
        } else {
View Full Code Here

            args[i] = expr.getArg(i).accept(this, c);
            context.add(c);
        }
        if (context.replace) {
            if (expr.getType().equals(Boolean.class)) {
                Predicate predicate = new PredicateOperation((Operator<Boolean>)expr.getOperator(), ImmutableList.copyOf(args));
                return !context.paths.isEmpty() ? exists(context, predicate) : predicate;
            } else {
                return new OperationImpl(expr.getType(), expr.getOperator(), ImmutableList.copyOf(args));
            }
        } else {
View Full Code Here

        assertMatches("cat_kittens.*_kittens.*\\.name", serialize(cat.kittens.any().kittens.any().name));
    }
   
    @Test
    public void Simple_BooleanOperation() {       
        Predicate predicate = cat.kittens.any().name.eq("Ruth123");       
        assertMatches("cat_kittens.*\\.name = Ruth123", serialize(predicate));
    }
View Full Code Here

TOP

Related Classes of com.mysema.query.types.Predicate

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.