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

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


/* 1345 */     return data;
/*      */   }
/*      */
/*      */   public Object visit(ASTCollectionMemberDeclaration node, Object data)
/*      */   {
/* 1350 */     ASTPath path = (ASTPath)node.jjtGetChild(0);
/*      */
/* 1353 */     ASTIdentifier id = (ASTIdentifier)node.jjtGetChild(1);
/* 1354 */     String alias = this.aliasManager.getAlias(id.identifier);
/* 1355 */     this.aliasManager.addAlias(path.getPath(), alias);
/*      */
/* 1357 */     addInnerJoinPath(path);
/*      */
/* 1359 */     return data;
/*      */   }
View Full Code Here


/* 1376 */     if (not)
/*      */     {
/* 1378 */       buf.append(" NOT ").append('(');
/*      */     }
/*      */
/* 1381 */     ASTPath fromPath = (ASTPath)fromNode;
/* 1382 */     addLeftJoinPath(fromPath);
/* 1383 */     String fromAlias = this.aliasManager.getAlias(fromPath.getPath());
/* 1384 */     JDBCAbstractEntityBridge fromEntity = (JDBCAbstractEntityBridge)fromPath.getEntity();
/*      */
/* 1386 */     if ((toNode instanceof ASTParameter))
/*      */     {
/* 1388 */       ASTParameter toParam = (ASTParameter)toNode;
/*      */
/* 1391 */       verifyParameterEntityType(toParam.number, fromEntity);
/*      */
/* 1393 */       this.inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromEntity));
/*      */
/* 1395 */       SQLUtil.getWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, buf);
/*      */     }
/*      */     else
/*      */     {
/* 1399 */       ASTPath toPath = (ASTPath)toNode;
/* 1400 */       addLeftJoinPath(toPath);
/* 1401 */       String toAlias = this.aliasManager.getAlias(toPath.getPath());
/* 1402 */       JDBCAbstractEntityBridge toEntity = (JDBCAbstractEntityBridge)toPath.getEntity();
/*      */
/* 1405 */       if (!fromEntity.equals(toEntity))
/*      */       {
/* 1407 */         throw new IllegalStateException("Only like types can be compared: from entity=" + fromEntity.getEntityName() + " to entity=" + toEntity.getEntityName());
/*      */       }
View Full Code Here

/*      */     }
/*      */
/* 1433 */     for (Iterator iter = paths.values().iterator(); iter.hasNext(); )
/*      */     {
/* 1435 */       String leftAlias = alias;
/* 1436 */       ASTPath path = (ASTPath)iter.next();
/* 1437 */       for (int i = 1; i < path.size(); i++)
/*      */       {
/* 1439 */         if (!path.isCMRField(i))
/*      */           continue;
/* 1441 */         String curPath = path.getPath(i);
/* 1442 */         String joinAlias = this.aliasManager.getAlias(curPath);
/*      */
/* 1444 */         if (this.joinedAliases.add(joinAlias))
/*      */         {
/* 1446 */           JDBCAbstractCMRFieldBridge cmrField = (JDBCAbstractCMRFieldBridge)path.getCMRField(i);
/* 1447 */           JDBCAbstractEntityBridge joinEntity = (JDBCAbstractEntityBridge)cmrField.getRelatedEntity();
/*      */
/* 1449 */           JDBCRelationMetaData relation = cmrField.getMetaData().getRelationMetaData();
/*      */
/* 1451 */           String join = path.innerJoin ? " INNER JOIN " : " LEFT OUTER JOIN ";
View Full Code Here

/*      */       {
/* 1503 */         paths = new HashMap();
/* 1504 */         this.joinPaths.put(alias, paths);
/*      */       }
/*      */
/* 1507 */       ASTPath oldPath = (ASTPath)paths.put(path, path);
/* 1508 */       if ((oldPath != null) && (oldPath.innerJoin))
/*      */       {
/* 1510 */         path.innerJoin = true;
/*      */       }
/*      */     }
View Full Code Here

/*  384 */     if (not)
/*      */     {
/*  386 */       buf.append(" NOT ").append('(');
/*      */     }
/*      */
/*  391 */     ASTPath fromPath = (ASTPath)fromNode;
/*  392 */     addJoinPath(fromPath);
/*  393 */     String fromAlias = this.aliasManager.getAlias(fromPath.getPath());
/*  394 */     JDBCEntityBridge fromEntity = (JDBCEntityBridge)fromPath.getEntity();
/*      */
/*  396 */     if ((toNode instanceof ASTParameter))
/*      */     {
/*  398 */       ASTParameter toParam = (ASTParameter)toNode;
/*      */
/*  401 */       verifyParameterEntityType(toParam.number, fromEntity);
/*      */
/*  403 */       this.inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromEntity));
/*      */
/*  405 */       SQLUtil.getWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, buf);
/*      */     }
/*      */     else
/*      */     {
/*  411 */       ASTPath toPath = (ASTPath)toNode;
/*  412 */       addJoinPath(toPath);
/*  413 */       String toAlias = this.aliasManager.getAlias(toPath.getPath());
/*  414 */       JDBCEntityBridge toEntity = (JDBCEntityBridge)toPath.getEntity();
/*      */
/*  417 */       if (!fromEntity.equals(toEntity))
/*      */       {
/*  419 */         throw new IllegalStateException("Only like types can be compared: from entity=" + fromEntity.getEntityName() + " to entity=" + toEntity.getEntityName());
/*      */       }
View Full Code Here

/*  556 */       orderByNode.jjtAccept(this, orderBy);
/*      */
/*  559 */       for (int i = 0; i < orderByNode.jjtGetNumChildren(); i++)
/*      */       {
/*  561 */         Node orderByPath = orderByNode.jjtGetChild(i);
/*  562 */         ASTPath path = (ASTPath)orderByPath.jjtGetChild(0);
/*  563 */         if (isSelected(path))
/*      */           continue;
/*  565 */         select.append(", ");
/*  566 */         path.jjtAccept(this, select);
/*      */       }
/*      */
/*      */     }
/*      */
/*  571 */     if (limitNode != null)
View Full Code Here

/*      */     Iterator iter;
/*  719 */     if (!this.allJoinPaths.isEmpty())
/*      */     {
/*  721 */       for (iter = this.allJoinPaths.iterator(); iter.hasNext(); )
/*      */       {
/*  723 */         ASTPath path = (ASTPath)iter.next();
/*  724 */         for (int i = 0; i < path.size(); i++)
/*      */         {
/*  726 */           declareTables(path, i, buf);
/*      */         }
/*      */       }
/*      */     }
/*      */     Iterator iter;
/*  732 */     if (!this.allCollectionMemberJoinPaths.isEmpty())
/*      */     {
/*  734 */       for (iter = this.allCollectionMemberJoinPaths.values().iterator(); iter.hasNext(); )
/*      */       {
/*  736 */         ASTPath path = (ASTPath)iter.next();
/*      */
/*  738 */         for (int i = 0; i < path.size() - 1; i++)
/*      */         {
/*  740 */           declareTables(path, i, buf);
/*      */         }
/*      */       }
/*      */     }
/*      */     Iterator iter;
/*  746 */     if (!this.allLeftJoinPaths.isEmpty())
/*      */     {
/*  748 */       Set allLeftJoins = new HashSet();
/*  749 */       for (Iterator iter = this.allLeftJoinPaths.values().iterator(); iter.hasNext(); )
/*      */       {
/*  751 */         allLeftJoins.addAll((Set)iter.next());
/*      */       }
/*      */
/*  755 */       for (iter = allLeftJoins.iterator(); iter.hasNext(); )
/*      */       {
/*  757 */         ASTPath path = (ASTPath)iter.next();
/*      */
/*  759 */         for (int i = 0; i < path.size() - 1; i++)
/*      */         {
/*  761 */           declareTables(path, i, buf);
/*      */         }
/*      */       }
/*      */     }
View Full Code Here

/*  802 */       return;
/*      */     }
/*      */
/*  805 */     for (Iterator iter = paths.iterator(); iter.hasNext(); )
/*      */     {
/*  807 */       ASTPath path = (ASTPath)iter.next();
/*      */
/*  809 */       JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)path.getCMRField();
/*  810 */       String parentAlias = this.aliasManager.getAlias(parentPath);
/*      */
/*  812 */       if (cmrField.getRelationMetaData().isForeignKeyMappingStyle())
/*      */       {
/*  814 */         JDBCEntityBridge childEntity = (JDBCEntityBridge)cmrField.getRelatedEntity();
/*  815 */         String childAlias = this.aliasManager.getAlias(path.getPath());
/*      */
/*  817 */         buf.append(" LEFT JOIN ").append(childEntity.getQualifiedTableName()).append(' ').append(childAlias).append(" ON ");
/*      */
/*  822 */         SQLUtil.getJoinClause(cmrField, parentAlias, childAlias, buf);
/*      */       }
/*      */       else
/*      */       {
/*  826 */         String relationTableAlias = this.aliasManager.getRelationTableAlias(path.getPath());
/*  827 */         buf.append(" LEFT JOIN ").append(cmrField.getQualifiedTableName()).append(' ').append(relationTableAlias).append(" ON ");
/*      */
/*  832 */         SQLUtil.getRelationTableJoinClause(cmrField, parentAlias, relationTableAlias, buf);
/*      */       }
/*      */     }
View Full Code Here

/*      */     Iterator iter;
/*  841 */     if (!this.ctermJoinPaths.isEmpty())
/*      */     {
/*  843 */       for (iter = this.ctermJoinPaths.iterator(); iter.hasNext(); )
/*      */       {
/*  845 */         ASTPath path = (ASTPath)iter.next();
/*  846 */         for (int i = 0; i < path.size(); i++)
/*      */         {
/*  848 */           createThetaJoin(path, i, joinedAliases, buf);
/*      */         }
/*      */       }
/*      */     }
/*      */     Iterator iter;
/*  854 */     if (!this.ctermCollectionMemberJoinPaths.isEmpty())
/*      */     {
/*  856 */       for (iter = this.ctermCollectionMemberJoinPaths.entrySet().iterator(); iter.hasNext(); )
/*      */       {
/*  858 */         Map.Entry entry = (Map.Entry)iter.next();
/*  859 */         String childAlias = (String)entry.getKey();
/*  860 */         ASTPath path = (ASTPath)entry.getValue();
/*      */
/*  863 */         createThetaJoin(path, path.size() - 1, joinedAliases, childAlias, buf);
/*      */
/*  866 */         for (int i = 0; i < path.size() - 1; i++)
/*      */         {
/*  868 */           createThetaJoin(path, i, joinedAliases, buf);
/*      */         }
/*      */       }
/*      */     }
/*      */     Iterator iter;
/*  874 */     if (!this.ctermLeftJoinPaths.isEmpty())
/*      */     {
/*  876 */       Set allLeftJoins = new HashSet();
/*  877 */       for (Iterator iter = this.ctermLeftJoinPaths.values().iterator(); iter.hasNext(); )
/*      */       {
/*  879 */         allLeftJoins.addAll((Set)iter.next());
/*      */       }
/*      */
/*  883 */       for (iter = allLeftJoins.iterator(); iter.hasNext(); )
/*      */       {
/*  885 */         ASTPath path = (ASTPath)iter.next();
/*      */
/*  887 */         for (int i = 0; i < path.size() - 1; i++)
/*      */         {
/*  889 */           createThetaJoin(path, i, joinedAliases, buf);
/*      */         }
/*      */       }
/*      */     }
View Full Code Here

/*      */
/*      */   public Object visit(ASTCollectionMemberDeclaration node, Object data)
/*      */   {
/*  944 */     StringBuffer buf = (StringBuffer)data;
/*      */
/*  947 */     ASTPath path = (ASTPath)node.jjtGetChild(0);
/*      */
/*  950 */     this.declaredPaths.add(path.getPath());
/*      */
/*  953 */     JDBCEntityBridge entity = (JDBCEntityBridge)path.getEntity();
/*      */
/*  956 */     ASTIdentifier id = (ASTIdentifier)node.jjtGetChild(1);
/*      */
/*  959 */     String alias = this.aliasManager.getAlias(id.identifier);
/*      */
/*  962 */     addCollectionMemberJoinPath(alias, path);
/*      */
/*  965 */     this.aliasManager.addAlias(path.getPath(), alias);
/*      */
/*  967 */     buf.append(entity.getQualifiedTableName());
/*  968 */     buf.append(' ');
/*  969 */     buf.append(alias);
/*  970 */     leftJoins(path.getPath(), buf);
/*      */
/*  972 */     if ((this.onFindCMRJoin != null) && (alias.equals(this.selectAlias)))
/*      */     {
/*  974 */       buf.append(this.onFindCMRJoin);
/*  975 */       this.onFindCMRJoin = null;
/*      */     }
/*      */
/*  979 */     JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)path.getCMRField();
/*  980 */     if (cmrField.getRelationMetaData().isTableMappingStyle())
/*      */     {
/*  982 */       String relationTableAlias = this.aliasManager.getRelationTableAlias(path.getPath());
/*  983 */       buf.append(", ").append(cmrField.getQualifiedTableName()).append(' ').append(relationTableAlias);
/*      */     }
/*      */
/*  989 */     return buf;
/*      */   }
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.