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

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


/*      */
/* 1019 */     Node child0 = node.jjtGetChild(0);
/*      */
/* 1021 */     if ((child0 instanceof ASTPath))
/*      */     {
/* 1023 */       ASTPath path = (ASTPath)child0;
/*      */
/* 1025 */       if (path.isCMPField())
/*      */       {
/* 1028 */         JDBCCMPFieldBridge selectField = (JDBCCMPFieldBridge)path.getCMPField();
/* 1029 */         this.selectManager = ((JDBCStoreManager)selectField.getManager());
/* 1030 */         this.selectObject = selectField;
/* 1031 */         setTypeFactory(this.selectManager.getJDBCTypeFactory());
/*      */
/* 1033 */         addJoinPath(path);
/* 1034 */         this.selectAlias = this.aliasManager.getAlias(path.getPath(path.size() - 2));
/* 1035 */         SQLUtil.getColumnNamesClause(selectField, this.selectAlias, buf);
/*      */       }
/*      */       else
/*      */       {
/* 1040 */         JDBCEntityBridge selectEntity = (JDBCEntityBridge)path.getEntity();
/* 1041 */         this.selectManager = ((JDBCStoreManager)selectEntity.getManager());
/* 1042 */         this.selectObject = selectEntity;
/* 1043 */         setTypeFactory(this.selectManager.getJDBCTypeFactory());
/* 1044 */         selectEntity(path, node.distinct, buf);
/*      */       }
/*      */
/*      */     }
/*      */     else
/*      */     {
/* 1050 */       ASTPath path = getPathFromChildren(child0);
/*      */
/* 1052 */       if (path == null)
/*      */       {
/* 1054 */         throw new IllegalStateException("The function in SELECT clause does not contain a path expression.");
/*      */       }
/*      */
/* 1057 */       if (path.isCMPField())
/*      */       {
/* 1059 */         JDBCCMPFieldBridge selectField = (JDBCCMPFieldBridge)path.getCMPField();
/* 1060 */         this.selectManager = ((JDBCStoreManager)selectField.getManager());
/*      */       }
/* 1062 */       else if (path.isCMRField())
/*      */       {
/* 1064 */         JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)path.getCMRField();
/* 1065 */         this.selectManager = ((JDBCStoreManager)cmrField.getEntity().getManager());
/* 1066 */         addJoinPath(path);
/*      */       }
/*      */       else
/*      */       {
/* 1070 */         JDBCEntityBridge entity = (JDBCEntityBridge)path.getEntity();
/* 1071 */         this.selectManager = ((JDBCStoreManager)entity.getManager());
/* 1072 */         addJoinPath(path);
/*      */       }
/*      */
/* 1075 */       setTypeFactory(this.selectManager.getJDBCTypeFactory());
View Full Code Here


/* 1094 */     StringBuffer buf = (StringBuffer)data;
/*      */
/* 1096 */     Node child0 = node.jjtGetChild(0);
/* 1097 */     if ((child0 instanceof ASTPath))
/*      */     {
/* 1099 */       ASTPath path = (ASTPath)child0;
/*      */
/* 1101 */       if (path.isCMRField())
/*      */       {
/* 1103 */         JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)path.getCMRField();
/* 1104 */         if (cmrField.getRelationMetaData().isTableMappingStyle())
/*      */         {
/* 1106 */           existsClause(path, buf, !node.not);
/* 1107 */           return buf;
/*      */         }
/*      */       }
/*      */
/* 1111 */       String alias = this.aliasManager.getAlias(path.getPath(path.size() - 2));
/* 1112 */       JDBCFieldBridge field = (JDBCFieldBridge)path.getField();
/*      */
/* 1118 */       if (field.getJDBCType() == null)
/*      */       {
/* 1120 */         existsClause(path, buf, !node.not);
/* 1121 */         return buf;
View Full Code Here

/*      */   }
/*      */
/*      */   public Object visit(ASTIsEmpty node, Object data)
/*      */   {
/* 1165 */     StringBuffer buf = (StringBuffer)data;
/* 1166 */     ASTPath path = (ASTPath)node.jjtGetChild(0);
/*      */
/* 1168 */     existsClause(path, buf, !node.not);
/* 1169 */     return buf;
/*      */   }
View Full Code Here

/*      */
/*      */   public Object visit(ASTMemberOf node, Object data)
/*      */   {
/* 1177 */     StringBuffer buf = (StringBuffer)data;
/*      */
/* 1180 */     ASTPath toPath = (ASTPath)node.jjtGetChild(1);
/*      */
/* 1182 */     JDBCCMRFieldBridge toCMRField = (JDBCCMRFieldBridge)toPath.getCMRField();
/*      */
/* 1184 */     JDBCEntityBridge toChildEntity = (JDBCEntityBridge)toPath.getEntity();
/*      */
/* 1186 */     String pathStr = toPath.getPath(toPath.size() - 2);
/* 1187 */     String toParentAlias = this.aliasManager.getAlias(pathStr);
/* 1188 */     String toChildAlias = this.aliasManager.getAlias(toPath.getPath());
/* 1189 */     String relationTableAlias = null;
/* 1190 */     if (toCMRField.getRelationMetaData().isTableMappingStyle())
/*      */     {
/* 1192 */       relationTableAlias = this.aliasManager.getRelationTableAlias(toPath.getPath());
/*      */     }
/*      */
/* 1196 */     String fromAlias = null;
/* 1197 */     int fromParamNumber = -1;
/* 1198 */     if ((node.jjtGetChild(0) instanceof ASTParameter))
/*      */     {
/* 1200 */       ASTParameter fromParam = (ASTParameter)node.jjtGetChild(0);
/*      */
/* 1203 */       verifyParameterEntityType(fromParam.number, toChildEntity);
/*      */
/* 1205 */       fromParamNumber = fromParam.number;
/*      */     }
/*      */     else
/*      */     {
/* 1209 */       ASTPath fromPath = (ASTPath)node.jjtGetChild(0);
/* 1210 */       addJoinPath(fromPath);
/*      */
/* 1212 */       JDBCEntityBridge fromEntity = (JDBCEntityBridge)fromPath.getEntity();
/* 1213 */       fromAlias = this.aliasManager.getAlias(fromPath.getPath());
/*      */
/* 1216 */       if (!fromEntity.equals(toChildEntity))
/*      */       {
/* 1218 */         throw new IllegalStateException("Only like types can be compared: from entity=" + fromEntity.getEntityName() + " to entity=" + toChildEntity.getEntityName());
/*      */       }
View Full Code Here

/*      */     {
/* 1337 */       buf.append(" NOT ").append('(');
/* 1338 */       comparison = "=";
/*      */     }
/*      */
/* 1342 */     ASTPath fromPath = (ASTPath)node.jjtGetChild(0);
/* 1343 */     addJoinPath(fromPath);
/* 1344 */     String fromAlias = this.aliasManager.getAlias(fromPath.getPath(fromPath.size() - 2));
/* 1345 */     JDBCCMPFieldBridge fromCMPField = (JDBCCMPFieldBridge)fromPath.getCMPField();
/*      */
/* 1347 */     Node toNode = node.jjtGetChild(1);
/* 1348 */     if ((toNode instanceof ASTParameter))
/*      */     {
/* 1350 */       ASTParameter toParam = (ASTParameter)toNode;
/*      */
/* 1353 */       Class parameterType = getParameterType(toParam.number);
/* 1354 */       if (!fromCMPField.getFieldType().equals(parameterType))
/*      */       {
/* 1356 */         throw new IllegalStateException("Only like types can be compared: from CMP field=" + fromCMPField.getFieldType() + " to parameter=" + parameterType);
/*      */       }
/*      */
/* 1362 */       this.inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromCMPField));
/* 1363 */       SQLUtil.getWhereClause(fromCMPField.getJDBCType(), fromAlias, comparison, buf);
/*      */     }
/*      */     else
/*      */     {
/* 1367 */       ASTPath toPath = (ASTPath)toNode;
/* 1368 */       addJoinPath(toPath);
/* 1369 */       String toAlias = this.aliasManager.getAlias(toPath.getPath(toPath.size() - 2));
/* 1370 */       JDBCCMPFieldBridge toCMPField = (JDBCCMPFieldBridge)toPath.getCMPField();
/*      */
/* 1373 */       if (!fromCMPField.getFieldType().equals(toCMPField.getFieldType()))
/*      */       {
/* 1375 */         throw new IllegalStateException("Only like types can be compared: from CMP field=" + fromCMPField.getFieldType() + " to CMP field=" + toCMPField.getFieldType());
/*      */       }
View Full Code Here

/*      */   public Object visit(ASTCount node, Object data)
/*      */   {
/* 1549 */     StringBuffer buf = (StringBuffer)data;
/* 1550 */     node.setResultType(this.returnType);
/*      */
/* 1553 */     ASTPath cntPath = (ASTPath)node.jjtGetChild(0);
/*      */     Object[] args;
/*      */     Object[] args;
/* 1554 */     if (cntPath.isCMPField())
/*      */     {
/* 1556 */       args = new Object[] { node.distinct, new NodeStringWrapper(cntPath) };
/*      */     }
/*      */     else
/*      */     {
/* 1560 */       JDBCEntityBridge entity = (JDBCEntityBridge)cntPath.getEntity();
/* 1561 */       JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields();
/* 1562 */       if (pkFields.length > 1)
/*      */       {
/* 1564 */         this.countCompositePk = true;
/* 1565 */         this.forceDistinct = (node.distinct.length() > 0);
/* 1566 */         selectEntity(cntPath, this.forceDistinct, buf);
/* 1567 */         return buf;
/*      */       }
/*      */
/* 1572 */       String alias = this.aliasManager.getAlias(cntPath.getPath());
/* 1573 */       StringBuffer keyColumn = new StringBuffer(20);
/* 1574 */       SQLUtil.getColumnNamesClause(pkFields[0], alias, keyColumn);
/* 1575 */       args = new Object[] { node.distinct, keyColumn.toString() };
/*      */     }
/*      */
View Full Code Here

/*      */
/*      */     }
/* 1853 */     else if ((this.selectObject instanceof SelectFunction))
/*      */     {
/* 1855 */       Node funcNode = (Node)this.selectObject;
/* 1856 */       ASTPath fieldPath = getPathFromChildren(funcNode);
/* 1857 */       if (fieldPath.getCMPField() == cmpField)
/*      */       {
/* 1859 */         selected = true;
/*      */       }
/*      */     }
/*      */
View Full Code Here

/*      */
/*  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);
/*      */       }
/*      */
View Full Code Here

/*  643 */     StringBuffer sql = (StringBuffer)data;
/*      */
/*  645 */     Node child0 = node.jjtGetChild(0);
/*  646 */     if ((child0 instanceof ASTPath))
/*      */     {
/*  648 */       ASTPath path = (ASTPath)child0;
/*  649 */       addLeftJoinPath(path);
/*      */
/*  651 */       JDBCFieldBridge field = (JDBCFieldBridge)path.getField();
/*      */
/*  653 */       if ((field instanceof JDBCAbstractCMRFieldBridge))
/*      */       {
/*  655 */         JDBCAbstractCMRFieldBridge cmrField = (JDBCAbstractCMRFieldBridge)field;
/*      */         JDBCFieldBridge[] keyFields;
/*      */         String alias;
/*      */         JDBCFieldBridge[] keyFields;
/*  659 */         if (cmrField.hasForeignKey())
/*      */         {
/*  661 */           String alias = this.aliasManager.getAlias(path.getPath(path.size() - 2));
/*  662 */           keyFields = cmrField.getForeignKeyFields();
/*      */         }
/*      */         else
/*      */         {
/*  666 */           alias = this.aliasManager.getAlias(path.getPath());
/*      */           JDBCFieldBridge[] keyFields;
/*  667 */           if (cmrField.getMetaData().getRelationMetaData().isTableMappingStyle())
/*      */           {
/*  669 */             keyFields = cmrField.getRelatedCMRField().getEntity().getPrimaryKeyFields();
/*      */           }
/*      */           else
/*      */           {
/*  673 */             keyFields = cmrField.getRelatedCMRField().getForeignKeyFields();
/*      */           }
/*      */         }
/*      */
/*  677 */         SQLUtil.getIsNullClause(node.not, keyFields, alias, sql);
/*      */       }
/*      */       else
/*      */       {
/*  681 */         String alias = this.aliasManager.getAlias(path.getPath(path.size() - 2));
/*  682 */         SQLUtil.getIsNullClause(node.not, field, alias, sql);
/*      */       }
/*      */     }
/*  685 */     else if ((child0 instanceof ASTParameter))
/*      */     {
View Full Code Here

TOP

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

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.