Package org.jboss.ejb.plugins.cmp.jdbc.bridge

Examples of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge$EntityState$MaskFieldIterator


      {
         buf.append(SQLUtil.NOT).append('(');
      }

      String fromAlias;
      JDBCEntityBridge fromEntity;
      ASTPath fromPath = (ASTPath) fromNode;
      addJoinPath(fromPath);
      fromAlias = aliasManager.getAlias(fromPath.getPath());
      fromEntity = (JDBCEntityBridge) fromPath.getEntity();

      if(toNode instanceof ASTParameter)
      {
         ASTParameter toParam = (ASTParameter) toNode;

         // can only compare like kind entities
         verifyParameterEntityType(toParam.number, fromEntity);

         inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromEntity));

         SQLUtil.getWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, buf);
      }
      else
      {
         String toAlias;
         JDBCEntityBridge toEntity;
         ASTPath toPath = (ASTPath) toNode;
         addJoinPath(toPath);
         toAlias = aliasManager.getAlias(toPath.getPath());
         toEntity = (JDBCEntityBridge) toPath.getEntity();

         // can only compare like kind entities
         if(!fromEntity.equals(toEntity))
         {
            throw new IllegalStateException("Only like types can be " +
               "compared: from entity=" +
               fromEntity.getEntityName() +
               " to entity=" + toEntity.getEntityName());
         }

         SQLUtil.getSelfCompareWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, toAlias, buf);
      }
View Full Code Here


         addJoinPath(path);

         if(cmrField.getRelationMetaData().isForeignKeyMappingStyle())
         {
            JDBCEntityBridge childEntity = (JDBCEntityBridge) cmrField.getRelatedEntity();
            String childAlias = aliasManager.getAlias(path.getPath());
            SQLUtil.getIsNullClause(!not, childEntity.getPrimaryKeyFields(), childAlias, buf);
         }
         else
         {
            String relationTableAlias = aliasManager.getRelationTableAlias(path.getPath());
            SQLUtil.getIsNullClause(!not, cmrField.getTableKeyFields(), relationTableAlias, buf);
         }
         return;
      }

      if(not)
      {
         buf.append(SQLUtil.NOT);
      }
      buf.append(SQLUtil.EXISTS).append('(');

      if(cmrField.getRelationMetaData().isForeignKeyMappingStyle())
      {
         JDBCEntityBridge childEntity = (JDBCEntityBridge) cmrField.getRelatedEntity();
         String childAlias = aliasManager.getAlias(path.getPath());

         buf.append(SQLUtil.SELECT);

         SQLUtil.getColumnNamesClause(childEntity.getPrimaryKeyFields(), childAlias, buf)
            .append(SQLUtil.FROM)
            .append(childEntity.getQualifiedTableName()).append(' ').append(childAlias)
            .append(SQLUtil.WHERE);
         SQLUtil.getJoinClause(cmrField, parentAlias, childAlias, buf);
      }
      else
      {
View Full Code Here

      {
         return;
      }

      JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge) path.getCMRField(i);
      JDBCEntityBridge entity = (JDBCEntityBridge) path.getEntity(i);

      buf.append(SQLUtil.COMMA)
         .append(entity.getQualifiedTableName())
         .append(' ')
         .append(aliasManager.getAlias(path.getPath(i)));
      leftJoins(path.getPath(i), buf);

      if(cmrField.getRelationMetaData().isTableMappingStyle())
View Full Code Here

         JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge) path.getCMRField();
         String parentAlias = aliasManager.getAlias(parentPath);

         if(cmrField.getRelationMetaData().isForeignKeyMappingStyle())
         {
            JDBCEntityBridge childEntity = (JDBCEntityBridge) cmrField.getRelatedEntity();
            String childAlias = aliasManager.getAlias(path.getPath());

            buf.append(SQLUtil.LEFT_JOIN)
               .append(childEntity.getQualifiedTableName())
               .append(' ')
               .append(childAlias)
               .append(SQLUtil.ON);
            SQLUtil.getJoinClause(cmrField, parentAlias, childAlias, buf);
         }
View Full Code Here

      // add this path to the list of declared paths
      declaredPaths.add(path.getPath());

      // get the entity at the end of this path
      JDBCEntityBridge entity = (JDBCEntityBridge) path.getEntity();

      // second arg is the identifier
      ASTIdentifier id = (ASTIdentifier) node.jjtGetChild(1);

      // get the alias
      String alias = aliasManager.getAlias(id.identifier);

      // add this path to the list of join paths so parent paths will be joined
      addCollectionMemberJoinPath(alias, path);

      // declare the alias mapping
      aliasManager.addAlias(path.getPath(), alias);

      buf.append(entity.getQualifiedTableName());
      buf.append(' ');
      buf.append(alias);
      leftJoins(path.getPath(), buf);

      if(onFindCMRJoin != null && alias.equals(selectAlias))
View Full Code Here

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

      ASTAbstractSchema schema = (ASTAbstractSchema) node.jjtGetChild(0);
      JDBCEntityBridge entity = (JDBCEntityBridge) schema.entity;
      ASTIdentifier id = (ASTIdentifier) node.jjtGetChild(1);

      String alias = aliasManager.getAlias(id.identifier);
      buf.append(entity.getQualifiedTableName())
         .append(' ')
         .append(alias);
      leftJoins(id.identifier, buf);

      if(onFindCMRJoin != null && alias.equals(selectAlias))
View Full Code Here

            SQLUtil.getColumnNamesClause(selectField, selectAlias, buf);
         }
         else
         {
            // set the select object
            JDBCEntityBridge selectEntity = (JDBCEntityBridge) path.getEntity();
            selectManager = (JDBCStoreManager) selectEntity.getManager();
            selectObject = selectEntity;
            setTypeFactory(selectManager.getJDBCTypeFactory());
            selectEntity(path, node.distinct, buf);
         }
      }
      else
      {
         // the function should take a path expresion as a parameter
         path = getPathFromChildren(child0);

         if(path == null)
         {
            throw new IllegalStateException("The function in SELECT clause does not contain a path expression.");
         }

         if(path.isCMPField())
         {
            JDBCCMPFieldBridge selectField = (JDBCCMPFieldBridge) path.getCMPField();
            selectManager = (JDBCStoreManager) selectField.getManager();
            if(selectField.getJDBCType().hasMapper())
               this.functionJDBCType = selectField.getJDBCType();
         }
         else if(path.isCMRField())
         {
            JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge) path.getCMRField();
            selectManager = (JDBCStoreManager) cmrField.getEntity().getManager();
            addJoinPath(path);
         }
         else
         {
            final JDBCEntityBridge entity = (JDBCEntityBridge) path.getEntity();
            selectManager = (JDBCStoreManager) entity.getManager();
            addJoinPath(path);
         }

         setTypeFactory(selectManager.getJDBCTypeFactory());
         selectObject = child0;
View Full Code Here

      // setup compare to vars first, so we can compre types in from vars
      ASTPath toPath = (ASTPath) node.jjtGetChild(1);

      JDBCCMRFieldBridge toCMRField = (JDBCCMRFieldBridge) toPath.getCMRField();

      JDBCEntityBridge toChildEntity = (JDBCEntityBridge) toPath.getEntity();

      String pathStr = toPath.getPath(toPath.size() - 2);
      String toParentAlias = aliasManager.getAlias(pathStr);
      String toChildAlias = aliasManager.getAlias(toPath.getPath());
      String relationTableAlias = null;
      if(toCMRField.getRelationMetaData().isTableMappingStyle())
      {
         relationTableAlias = aliasManager.getRelationTableAlias(toPath.getPath());
      }

      // setup from variables
      String fromAlias = null;
      int fromParamNumber = -1;
      if(node.jjtGetChild(0) instanceof ASTParameter)
      {
         ASTParameter fromParam = (ASTParameter) node.jjtGetChild(0);

         // can only compare like kind entities
         verifyParameterEntityType(fromParam.number, toChildEntity);

         fromParamNumber = fromParam.number;
      }
      else
      {
         ASTPath fromPath = (ASTPath) node.jjtGetChild(0);
         addJoinPath(fromPath);

         JDBCEntityBridge fromEntity = (JDBCEntityBridge) fromPath.getEntity();
         fromAlias = aliasManager.getAlias(fromPath.getPath());

         // can only compare like kind entities
         if(!fromEntity.equals(toChildEntity))
         {
            throw new IllegalStateException("Only like types can be " +
               "compared: from entity=" +
               fromEntity.getEntityName() +
               " to entity=" + toChildEntity.getEntityName());
         }
      }

      // add the path to the list of paths to left join
View Full Code Here

      {
         args = new Object[]{node.distinct, new NodeStringWrapper(cntPath)};
      }
      else
      {
         JDBCEntityBridge entity = (JDBCEntityBridge) cntPath.getEntity();
         final JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields();
         if(pkFields.length > 1)
         {
            countCompositePk = true;
            forceDistinct = node.distinct.length() > 0;
            selectEntity(cntPath, forceDistinct, buf);
View Full Code Here

      {
         selected = true;
      }
      else if(selectObject instanceof JDBCEntityBridge)
      {
         JDBCEntityBridge entity = (JDBCEntityBridge) selectObject;
         JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields();
         for(int pkInd = 0; pkInd < pkFields.length; ++pkInd)
         {
            if(pkFields[pkInd] == cmpField)
            {
               selected = true;
View Full Code Here

TOP

Related Classes of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge$EntityState$MaskFieldIterator

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.