Package javax.persistence.criteria

Examples of javax.persistence.criteria.Expression


        CriteriaQuery<Embed_ToOne> q = cb.createQuery(Embed_ToOne.class);
        Root<EntityA_Embed_ToOne> a = q.from(EntityA_Embed_ToOne.class);
        q.select(a.get(EntityA_Embed_ToOne_.embed));
        Subquery<EntityA_Embed_ToOne> sq = q.subquery(EntityA_Embed_ToOne.class);
        Root<EntityA_Embed_ToOne> a1 = sq.from(EntityA_Embed_ToOne.class);
        Expression n = a1.get(EntityA_Embed_ToOne_.embed).get(Embed_ToOne_.b);
        sq.where(cb.isNotNull(n));
        sq.select(a1);
        q.where(cb.exists(sq));
        q.orderBy(cb.asc(a.get(EntityA_Embed_ToOne_.embed)));
       
View Full Code Here


        CriteriaQuery<Integer> q = cb.createQuery(Integer.class);
        Root<EntityA_Coll_Embed_ToOne> a = q.from(EntityA_Coll_Embed_ToOne.class);
        Join<EntityA_Coll_Embed_ToOne, Embed_ToOne> e = a.join(EntityA_Coll_Embed_ToOne_.embed1s);
        Subquery<Set> sq1 = q.subquery(Set.class);
        Root<EntityA_Coll_Embed_ToOne> a1 = sq1.from(EntityA_Coll_Embed_ToOne.class);
        Expression e1 = a1.get(EntityA_Coll_Embed_ToOne_.embed1s);
        sq1.select(e1);

        Subquery<EntityB1> sq2 = q.subquery(EntityB1.class);
        Root<EntityA_Coll_Embed_ToOne> a2 = sq2.correlate(a);
        Join<EntityA_Coll_Embed_ToOne, Embed_ToOne> e2 = a2.join(EntityA_Coll_Embed_ToOne_.embed1s);
View Full Code Here

        Root<EntityA_Embed_Embed_ToMany> a = q.from(EntityA_Embed_Embed_ToMany.class);
        Expression<Embed_Embed_ToMany> e = a.get(EntityA_Embed_Embed_ToMany_.embed);
        q.select(e);
        Subquery<List> sq = q.subquery(List.class);
        Root<EntityA_Embed_Embed_ToMany> a1 = sq.from(EntityA_Embed_Embed_ToMany.class);
        Expression bs = a1.get(EntityA_Embed_Embed_ToMany_.embed).get(Embed_Embed_ToMany_.embed).
            get(Embed_ToMany_.bs);
        sq.select(bs);
        q.where(cb.exists(sq));
        assertEquivalence(q, jpql);
    }
View Full Code Here

        ListJoin<EntityA_Coll_Embed_Embed, Embed_Embed> e = a.join(EntityA_Coll_Embed_Embed_.embeds);
        q.orderBy(cb.asc(e.get(Embed_Embed_.intVal3)));
        q.multiselect(e, e.get(Embed_Embed_.intVal1), e.get(Embed_Embed_.embed).get(Embed_.intVal2));
        Subquery<List> sq = q.subquery(List.class);
        Root<EntityA_Coll_Embed_Embed> a1 = sq.from(EntityA_Coll_Embed_Embed.class);
        Expression e2 = a1.get(EntityA_Coll_Embed_Embed_.embeds);
        sq.select(e2);
        q.where(cb.exists(sq));
        executeExpectFail(q, jpql);
        executeExpectFail(jpql);
    }
View Full Code Here

     * @param y
     *            expression
     * @return modulus
     */
    public Expression<Integer> mod(Integer x, Expression<Integer> y){
        Expression xExp = internalLiteral(x);
        return new FunctionExpressionImpl(this.metamodel, ClassConstants.INTEGER, ExpressionMath.mod(((InternalSelection)xExp).getCurrentNode(),((InternalSelection)y).getCurrentNode()), buildList(xExp,y), "mod");
    }
View Full Code Here

     */
    public <T> Expression<T> function(String name, Class<T> type, Expression<?>... args){
        if (args != null && args.length > 0){
        List<org.eclipse.persistence.expressions.Expression> params = new ArrayList<org.eclipse.persistence.expressions.Expression>();
        for (int index = 1; index < args.length; ++index){
            Expression x = args[index];
            params.add(((InternalSelection)x).getCurrentNode());
        }
       
        return new FunctionExpressionImpl<T>(metamodel, type, ((InternalSelection)args[0]).getCurrentNode().getFunctionWithArguments(name, params), buildList(args), name);
        }else{
View Full Code Here

     * @param y
     *            expression
     * @return modulus
     */
    public Expression<Integer> mod(Integer x, Expression<Integer> y){
        Expression xExp = literal(x);
        return new FunctionExpressionImpl(this.metamodel, ClassConstants.INTEGER, ExpressionMath.mod(((InternalSelection)xExp).getCurrentNode(),((InternalSelection)y).getCurrentNode()), buildList(xExp,y), "mod");
    }
View Full Code Here

     */
    public <T> Expression<T> function(String name, Class<T> type, Expression<?>... args){
        if (args != null && args.length > 0){
        List<org.eclipse.persistence.expressions.Expression> params = new ArrayList<org.eclipse.persistence.expressions.Expression>();
        for (int index = 1; index < args.length; ++index){
            Expression x = args[index];
            if (((InternalSelection)x).isFrom()){
                ((FromImpl)x).isLeaf = false;
            }
            params.add(((InternalSelection)x).getCurrentNode());
        }
View Full Code Here

  }

  @Override
  public String render(boolean isNegated, RenderingContext renderingContext) {
    final StringBuilder buffer = new StringBuilder();
    final Expression exp = getExpression();
    if ( ParameterExpressionImpl.class.isInstance( exp ) ) {
      // technically we only need to CAST (afaik) if expression and all values are parameters.
      // but checking for that condition could take long time on a lon value list
      final ParameterExpressionImpl parameterExpression = (ParameterExpressionImpl) exp;
      final SessionFactoryImplementor sfi = criteriaBuilder().getEntityManagerFactory().unwrap( SessionFactoryImplementor.class );
View Full Code Here

  @Override
  @SuppressWarnings("unchecked")
  public <Y, X extends Y> CriteriaUpdate<T> set(SingularAttribute<? super T, Y> singularAttribute, X value) {
    final Path<Y> attributePath = getRoot().get( singularAttribute );
    final Expression valueExpression = value == null
        ? criteriaBuilder().nullLiteral( attributePath.getJavaType() )
        : criteriaBuilder().literal( value );
    addAssignment( attributePath, valueExpression );
    return this;
  }
View Full Code Here

TOP

Related Classes of javax.persistence.criteria.Expression

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.