Examples of JDBCEntityBridge


Examples of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge

         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

Examples of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge

      {
         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

Examples of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge

         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

Examples of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge

      // 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

Examples of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge

   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

Examples of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge

            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

Examples of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge

      // 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

Examples of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge

      {
         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

Examples of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge

      {
         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

Examples of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge

      return selected;
   }

   private void selectEntity(ASTPath path, boolean distinct, StringBuffer buf)
   {
      JDBCEntityBridge selectEntity = (JDBCEntityBridge) path.getEntity();

      StringBuffer columnNamesClause = new StringBuffer(200);
      addJoinPath(path);
      selectAlias = aliasManager.getAlias(path.getPath());

      // get a list of all fields to be loaded
      // get the identifier for this field
      SQLUtil.getColumnNamesClause(selectEntity.getPrimaryKeyFields(), selectAlias, columnNamesClause);

      if(readAhead.isOnFind())
      {
         String eagerLoadGroupName = readAhead.getEagerLoadGroup();
         boolean[] loadGroupMask = selectEntity.getLoadGroupMask(eagerLoadGroupName);
         if(distinct)
            SQLUtil.appendSearchableColumnNamesClause(selectEntity.getTableFields(), loadGroupMask, selectAlias, columnNamesClause);
         else
            SQLUtil.appendColumnNamesClause(selectEntity.getTableFields(), loadGroupMask, selectAlias, columnNamesClause);

         try
         {
            leftJoinCMRList = JDBCAbstractQueryCommand.getLeftJoinCMRNodes(
               selectEntity, path.getPath(), readAhead.getLeftJoins(), declaredPaths);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.