Package javax.persistence.criteria

Examples of javax.persistence.criteria.Expression


              // converting to the column(s) associated with the entity's ID in the rendered SQL.  However, some DBs don't support
              // the multiple columns that would end up here for entities with composite IDs.  So, since we modify the query to
              // instead specify star since that's functionally equivalent and supported by all DBs.
          List<Expression<?>> argExprs = getArgumentExpressions();
          if (argExprs.size() == 1) {
                  Expression argExpr = argExprs.get(0);
                  if (argExpr instanceof Root<?>) {
                      Root<?> root = (Root<?>)argExpr;
                      if (root.getModel().getIdType() != null) {
                          buffer.append('*');
                          return;
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

  }

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

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

              // converting to the column(s) associated with the entity's ID in the rendered SQL.  However, some DBs don't support
              // the multiple columns that would end up here for entities with composite IDs.  So, since we modify the query to
              // instead specify star since that's functionally equivalent and supported by all DBs.
          List<Expression<?>> argExprs = getArgumentExpressions();
          if (argExprs.size() == 1) {
                  Expression argExpr = argExprs.get(0);
                  if (argExpr instanceof Root<?>) {
                      Root<?> root = (Root<?>)argExpr;
                      if (root.getModel().getIdType() != null) {
                          buffer.append('*');
                          return;
View Full Code Here

              // converting to the column(s) associated with the entity's ID in the rendered SQL.  However, some DBs don't support
              // the multiple columns that would end up here for entities with composite IDs.  So, since we modify the query to
              // instead specify star since that's functionally equivalent and supported by all DBs.
          List<Expression<?>> argExprs = getArgumentExpressions();
          if (argExprs.size() == 1) {
                  Expression argExpr = argExprs.get(0);
                  if (argExpr instanceof Root<?>) {
                      Root<?> root = (Root<?>)argExpr;
                      if (root.getModel().getIdType() != null) {
                          buffer.append('*');
                          return;
View Full Code Here

        CriteriaQuery<EntityA_Coll_String> q = cb.createQuery(EntityA_Coll_String.class);
        Root<EntityA_Coll_String> a = q.from(EntityA_Coll_String.class);
        q.select(a);
        Subquery<Set> sq = q.subquery(Set.class);
        Root<EntityA_Coll_String> a1 = sq.from(EntityA_Coll_String.class);
        Expression n = a1.get(EntityA_Coll_String_.nickNames);
        n.alias("n");
        sq.where(cb.like(n, "%1"));
        sq.select(n);
        q.where(cb.exists(sq));
        q.orderBy(cb.asc(a));
       
View Full Code Here

        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

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.