Package org.jboss.ejb.plugins.cmp.ejbql

Examples of org.jboss.ejb.plugins.cmp.ejbql.Node


   public Object visit(ASTNullComparison node, Object data)
   {
      StringBuffer buf = (StringBuffer) data;

      final Node child0 = node.jjtGetChild(0);
      if(child0 instanceof ASTPath)
      {
         ASTPath path = (ASTPath) child0;

         if(path.isCMRField())
View Full Code Here


      ASTPath fromPath = (ASTPath) node.jjtGetChild(0);
      addJoinPath(fromPath);
      String fromAlias = aliasManager.getAlias(fromPath.getPath(fromPath.size() - 2));
      JDBCCMPFieldBridge fromCMPField = (JDBCCMPFieldBridge) fromPath.getCMPField();

      Node toNode = node.jjtGetChild(1);
      if(toNode instanceof ASTParameter)
      {
         ASTParameter toParam = (ASTParameter) toNode;

         // can only compare like kind entities
View Full Code Here

    * compreEntity(arg0, arg1)
    */
   public Object visit(ASTEntityComparison node, Object data)
   {
      StringBuffer buf = (StringBuffer) data;
      Node arg0 = node.jjtGetChild(0);
      Node arg1 = node.jjtGetChild(1);
      if(node.opp.equals(SQLUtil.NOT_EQUAL))
      {
         compareEntity(true, arg0, arg1, buf);
      }
      else
View Full Code Here

   public Object visit(ASTLimitOffset node, Object data)
   {
      int child = 0;
      if(node.hasOffset)
      {
         Node offsetNode = node.jjtGetChild(child++);
         if(offsetNode instanceof ASTParameter)
         {
            ASTParameter param = (ASTParameter) offsetNode;
            Class parameterType = getParameterType(param.number);
            if(int.class != parameterType && Integer.class != parameterType)
            {
               throw new UnsupportedOperationException("OFFSET parameter must be an int");
            }
            offsetParam = param.number;
         }
         else
         {
            ASTExactNumericLiteral param = (ASTExactNumericLiteral) offsetNode;
            offsetValue = (int) param.value;
         }
      }
      if(node.hasLimit)
      {
         Node limitNode = node.jjtGetChild(child);
         if(limitNode instanceof ASTParameter)
         {
            ASTParameter param = (ASTParameter) limitNode;
            Class parameterType = getParameterType(param.number);
            if(int.class != parameterType && Integer.class != parameterType)
View Full Code Here

    */
   private ASTPath getPathFromChildren(Node selectFunction)
   {
      for(int childInd = 0; childInd < selectFunction.jjtGetNumChildren(); ++childInd)
      {
         Node child = selectFunction.jjtGetChild(childInd);
         if(child instanceof ASTPath)
         {
            return (ASTPath) child;
         }
         else if(child instanceof SelectFunction)
         {
            Node path = getPathFromChildren(child);
            if(path != null)
            {
               return (ASTPath) path;
            }
         }
View Full Code Here

            }
         }
      }
      else if(selectObject instanceof SelectFunction)
      {
         Node funcNode = (Node) selectObject;
         ASTPath fieldPath = getPathFromChildren(funcNode);
         if(fieldPath.getCMPField() == cmpField)
         {
            selected = true;
         }
View Full Code Here

/*  256 */     throw new RuntimeException("Internal error: Found unknown node type in EJB-QL abstract syntax tree: node=" + node);
/*      */   }
/*      */
/*      */   public Object visit(ASTEJBQL node, Object data)
/*      */   {
/*  262 */     Node selectNode = node.jjtGetChild(0);
/*  263 */     Node fromNode = node.jjtGetChild(1);
/*      */
/*  266 */     StringBuffer selectClause = new StringBuffer(50);
/*  267 */     selectNode.jjtAccept(this, selectClause);
/*      */
/*  269 */     StringBuffer whereClause = null;
/*  270 */     StringBuffer orderByClause = null;
/*  271 */     for (int i = 2; i < node.jjtGetNumChildren(); i++)
/*      */     {
/*  273 */       Node childNode = node.jjtGetChild(i);
/*  274 */       if ((childNode instanceof ASTWhere))
/*      */       {
/*  276 */         whereClause = new StringBuffer(20);
/*  277 */         childNode.jjtAccept(this, whereClause);
/*      */       }
/*  279 */       else if ((childNode instanceof ASTOrderBy))
/*      */       {
/*  281 */         orderByClause = new StringBuffer();
/*  282 */         childNode.jjtAccept(this, orderByClause);
/*      */       } else {
/*  284 */         if (!(childNode instanceof ASTLimitOffset))
/*      */           continue;
/*  286 */         childNode.jjtAccept(this, null);
/*      */       }
/*      */
/*      */     }
/*      */
/*  291 */     StringBuffer fromClause = new StringBuffer(30);
View Full Code Here

/*      */   public Object visit(ASTLimitOffset node, Object data)
/*      */   {
/*  392 */     int child = 0;
/*  393 */     if (node.hasOffset)
/*      */     {
/*  395 */       Node offsetNode = node.jjtGetChild(child++);
/*  396 */       if ((offsetNode instanceof ASTParameter))
/*      */       {
/*  398 */         ASTParameter param = (ASTParameter)offsetNode;
/*  399 */         Class parameterType = getParameterType(param.number);
/*  400 */         if ((Integer.TYPE != parameterType) && (Integer.class != parameterType))
/*      */         {
/*  402 */           throw new IllegalStateException("OFFSET parameter must be an int");
/*      */         }
/*  404 */         this.offsetParam = param.number;
/*      */       }
/*      */       else
/*      */       {
/*  408 */         ASTExactNumericLiteral param = (ASTExactNumericLiteral)offsetNode;
/*  409 */         this.offsetValue = (int)param.value;
/*      */       }
/*      */     }
/*      */
/*  413 */     if (node.hasLimit)
/*      */     {
/*  415 */       Node limitNode = node.jjtGetChild(child);
/*  416 */       if ((limitNode instanceof ASTParameter))
/*      */       {
/*  418 */         ASTParameter param = (ASTParameter)limitNode;
/*  419 */         Class parameterType = getParameterType(param.number);
/*  420 */         if ((Integer.TYPE != parameterType) && (Integer.class != parameterType))
View Full Code Here

/*      */
/*      */   public Object visit(ASTSelect select, Object data)
/*      */   {
/*  437 */     StringBuffer sql = (StringBuffer)data;
/*      */
/*  439 */     Node child0 = select.jjtGetChild(0);
/*      */
/*  441 */     if ((child0 instanceof ASTPath))
/*      */     {
/*  443 */       ASTPath path = (ASTPath)child0;
/*      */
/*  445 */       if (path.isCMPField())
/*      */       {
/*  448 */         JDBCFieldBridge selectField = path.getCMPField();
/*  449 */         this.selectManager = selectField.getManager();
/*  450 */         this.selectObject = selectField;
/*  451 */         setTypeFactory(this.selectManager.getJDBCTypeFactory());
/*      */
/*  455 */         addInnerJoinPath(path);
/*      */
/*  457 */         String alias = this.aliasManager.getAlias(path.getPath(path.size() - 2));
/*  458 */         SQLUtil.getColumnNamesClause(selectField, alias, sql);
/*      */       }
/*      */       else
/*      */       {
/*  462 */         JDBCAbstractEntityBridge selectEntity = (JDBCAbstractEntityBridge)path.getEntity();
/*  463 */         this.selectManager = selectEntity.getManager();
/*  464 */         this.selectObject = selectEntity;
/*  465 */         setTypeFactory(selectEntity.getManager().getJDBCTypeFactory());
/*      */
/*  467 */         String alias = this.aliasManager.getAlias(path.getPath());
/*  468 */         if (select.distinct)
/*      */         {
/*  470 */           SQLUtil.getSearchableColumnNamesClause(selectEntity.getTableFields(), alias, sql);
/*      */         }
/*      */         else
/*      */         {
/*  474 */           SQLUtil.getColumnNamesClause(selectEntity.getTableFields(), alias, sql);
/*      */         }
/*      */
/*  491 */         addLeftJoinPath(path);
/*      */       }
/*      */
/*      */     }
/*      */     else
/*      */     {
/*  497 */       ASTPath path = getPathFromChildren(child0);
/*      */
/*  499 */       if (path == null)
/*      */       {
/*  501 */         throw new IllegalStateException("The function in SELECT clause does not contain a path expression.");
/*      */       }
/*      */
/*  504 */       if (path.isCMPField())
/*      */       {
/*  506 */         JDBCFieldBridge selectField = path.getCMPField();
/*  507 */         this.selectManager = selectField.getManager();
/*  508 */         setTypeFactory(this.selectManager.getJDBCTypeFactory());
/*      */       }
/*  510 */       else if (path.isCMRField())
/*      */       {
/*  512 */         JDBCFieldBridge cmrField = (JDBCFieldBridge)path.getCMRField();
/*  513 */         this.selectManager = cmrField.getManager();
/*  514 */         setTypeFactory(this.selectManager.getJDBCTypeFactory());
/*  515 */         addLeftJoinPath(path);
/*      */       }
/*      */       else
/*      */       {
/*  519 */         JDBCAbstractEntityBridge entity = (JDBCAbstractEntityBridge)path.getEntity();
/*  520 */         this.selectManager = entity.getManager();
/*  521 */         setTypeFactory(this.selectManager.getJDBCTypeFactory());
/*  522 */         addLeftJoinPath(path);
/*      */       }
/*      */
/*  525 */       this.selectObject = child0;
/*  526 */       child0.jjtAccept(this, data);
/*      */     }
/*      */
/*  529 */     return data;
/*      */   }
View Full Code Here

/*      */
/*      */   public Object visit(ASTNullComparison node, Object data)
/*      */   {
/*  643 */     StringBuffer sql = (StringBuffer)data;
/*      */
/*  645 */     Node child0 = node.jjtGetChild(0);
/*  646 */     if ((child0 instanceof ASTPath))
/*      */     {
/*  648 */       ASTPath path = (ASTPath)child0;
/*  649 */       addLeftJoinPath(path);
/*      */
View Full Code Here

TOP

Related Classes of org.jboss.ejb.plugins.cmp.ejbql.Node

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.