Examples of JDBCCMPFieldBridge


Examples of org.jboss.as.cmp.jdbc.bridge.JDBCCMPFieldBridge

        if (child0 instanceof ASTPath) {
            path = (ASTPath) child0;

            if (path.isCMPField()) {
                // set the select object
                JDBCCMPFieldBridge selectField = (JDBCCMPFieldBridge) path.getCMPField();
                selectManager = (JDBCStoreManager) selectField.getManager();
                selectObject = selectField;
                setTypeFactory(selectManager.getJDBCTypeFactory());
                addJoinPath(path);
                selectAlias = aliasManager.getAlias(path.getPath(path.size() - 2));
                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 expression as a parameter
            path = getPathFromChildren(child0);

            if (path == null) {
                throw MESSAGES.functionInSelectNoPath();
            }

            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 {
View Full Code Here

Examples of org.jboss.as.cmp.jdbc.bridge.JDBCCMPFieldBridge

        // setup the from path
        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
            Class parameterType = getParameterType(toParam.number);
            if (!(fromCMPField.getFieldType().equals(parameterType))) {
                throw CmpMessages.MESSAGES.onlyLikeTypesCanBeCompared(fromCMPField.getFieldType().getName(), parameterType.getName());
            }

            inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromCMPField));
            SQLUtil.getWhereClause(fromCMPField.getJDBCType(), fromAlias, comparison, buf);
        } else {
            ASTPath toPath = (ASTPath) toNode;
            addJoinPath(toPath);
            String toAlias = aliasManager.getAlias(toPath.getPath(toPath.size() - 2));
            JDBCCMPFieldBridge toCMPField = (JDBCCMPFieldBridge) toPath.getCMPField();

            // can only compare like kind entities
            if (!(fromCMPField.getFieldType().equals(toCMPField.getFieldType()))) {
                throw CmpMessages.MESSAGES.onlyLikeTypesCanBeCompared(fromCMPField.getFieldType().getName(), toCMPField.getFieldType().getName());
            }

            SQLUtil.getSelfCompareWhereClause(fromCMPField, toCMPField, fromAlias, toAlias, comparison, buf);
        }
View Full Code Here

Examples of org.jboss.as.cmp.jdbc.bridge.JDBCCMPFieldBridge

        StringBuffer buf = (StringBuffer) data;
        if (!node.isCMPField()) {
            throw CmpMessages.MESSAGES.canOnlyVisitCmpNodes();
        }

        JDBCCMPFieldBridge cmpField = (JDBCCMPFieldBridge) node.getCMPField();

        // make sure this is mapped to a single column
        switch (node.type) {
            case EJBQLTypes.ENTITY_TYPE:
            case EJBQLTypes.VALUE_CLASS_TYPE:
                if (cmpField.getJDBCType().hasMapper() ||
                        cmpField.getJDBCType().getParameterSetter() != null) {
                    break;
                }
            case EJBQLTypes.UNKNOWN_TYPE:
                throw CmpMessages.MESSAGES.canNotVisitMultiColumnPath();
        }
View Full Code Here

Examples of org.jboss.as.cmp.jdbc.bridge.JDBCCMPFieldBridge

        JDBCEntityBridge.FieldIterator lockedIterator = null;
        if (hasLockedFields) {
            lockedIterator = entity.getLockedIterator(ctx);
            while (lockedIterator.hasNext()) {
                sql.append(SQLUtil.AND);
                JDBCCMPFieldBridge field = lockedIterator.next();
                if (field.getLockedValue(ctx) == null) {
                    SQLUtil.getIsNullClause(false, field, "", sql);
                    lockedIterator.remove();
                } else {
                    SQLUtil.getWhereClause(field, sql);
                }
            }
        }

        Connection con = null;
        PreparedStatement ps = null;
        int rowsAffected = 0;
        try {
            // create the statement
            if (log.isDebugEnabled()) {
                log.debug("Executing SQL: " + sql);
            }

            // get the connection
            con = entity.getDataSource().getConnection();
            ps = con.prepareStatement(sql.toString());

            // SET: set the dirty fields parameters
            int index = 1;
            dirtyIterator.reset();
            while (dirtyIterator.hasNext()) {
                index = dirtyIterator.next().setInstanceParameters(ps, index, ctx);
            }

            // WHERE: set primary key fields
            index = entity.setPrimaryKeyParameters(ps, index, ctx.getPrimaryKeyUnchecked());

            // WHERE: set optimistically locked field values
            if (hasLockedFields) {
                lockedIterator.reset();
                while (lockedIterator.hasNext()) {
                    JDBCCMPFieldBridge field = lockedIterator.next();
                    Object value = field.getLockedValue(ctx);
                    index = field.setArgumentParameters(ps, index, value);
                }
            }

            // execute statement
            rowsAffected = ps.executeUpdate();
View Full Code Here

Examples of org.jboss.as.cmp.jdbc.bridge.JDBCCMPFieldBridge

        int offset = toInt(parameters, compiler.getOffsetParam(), compiler.getOffsetValue());
        int limit = toInt(parameters, compiler.getLimitParam(), compiler.getLimitValue());

        JDBCEntityBridge selectEntity = null;
        JDBCCMPFieldBridge selectField = null;
        SelectFunction selectFunction = null;
        if (compiler.isSelectEntity()) {
            selectEntity = (JDBCEntityBridge) compiler.getSelectEntity();
        } else if (compiler.isSelectField()) {
            selectField = (JDBCCMPFieldBridge) compiler.getSelectField();
View Full Code Here

Examples of org.jboss.as.cmp.jdbc.bridge.JDBCCMPFieldBridge

            SQLUtil.getWhereClause(fromCMPField.getJDBCType(), fromAlias, comparison, buf);
        } else {
            ASTPath toPath = (ASTPath) toNode;
            addInnerJoinPath(toPath);
            String toAlias = aliasManager.getAlias(toPath.getPath(toPath.size() - 2));
            JDBCCMPFieldBridge toCMPField = (JDBCCMPFieldBridge) toPath.getCMPField();

            // can only compare like kind entities
            if (!(fromCMPField.getFieldType().equals(toCMPField.getFieldType()))) {
                throw CmpMessages.MESSAGES.onlyLikeTypesCanBeCompared(fromCMPField.getFieldType().getName(), toCMPField.getFieldType().getName());
            }

            SQLUtil.getSelfCompareWhereClause(fromCMPField, toCMPField, fromAlias, toAlias, comparison, buf);
        }
View Full Code Here

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

         path = (ASTPath) child0;

         if(path.isCMPField())
         {
            // set the select object
            JDBCCMPFieldBridge selectField = (JDBCCMPFieldBridge) path.getCMPField();
            selectManager = (JDBCStoreManager) selectField.getManager();
            selectObject = selectField;
            setTypeFactory(selectManager.getJDBCTypeFactory());
            addJoinPath(path);
            selectAlias = aliasManager.getAlias(path.getPath(path.size() - 2));
            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();
View Full Code Here

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

      // setup the from path
      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
         Class parameterType = getParameterType(toParam.number);
         if(!(fromCMPField.getFieldType().equals(parameterType)))
         {
            throw new IllegalStateException("Only like types can be " +
               "compared: from CMP field=" +
               fromCMPField.getFieldType() +
               " to parameter=" + parameterType);
         }

         inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromCMPField));
         SQLUtil.getWhereClause(fromCMPField.getJDBCType(), fromAlias, comparison, buf);
      }
      else
      {
         ASTPath toPath = (ASTPath) toNode;
         addJoinPath(toPath);
         String toAlias = aliasManager.getAlias(toPath.getPath(toPath.size() - 2));
         JDBCCMPFieldBridge toCMPField = (JDBCCMPFieldBridge) toPath.getCMPField();

         // can only compare like kind entities
         if(!(fromCMPField.getFieldType().equals(toCMPField.getFieldType())))
         {
            throw new IllegalStateException("Only like types can be " +
               "compared: from CMP field=" +
               fromCMPField.getFieldType() +
               " to CMP field=" + toCMPField.getFieldType());
         }

         SQLUtil.getSelfCompareWhereClause(fromCMPField, toCMPField, fromAlias, toAlias, comparison, buf);
      }
View Full Code Here

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

      {
         throw new IllegalStateException("Can only visit cmp valued path " +
            "node. Should have been handled at a higher level.");
      }

      JDBCCMPFieldBridge cmpField = (JDBCCMPFieldBridge) node.getCMPField();

      // make sure this is mapped to a single column
      switch(node.type)
      {
         case EJBQLTypes.ENTITY_TYPE:
         case EJBQLTypes.VALUE_CLASS_TYPE:
            if(cmpField.getJDBCType().hasMapper() ||
               cmpField.getJDBCType().getParameterSetter() != null)
            {
               break;
            }
         case EJBQLTypes.UNKNOWN_TYPE:
            throw new IllegalStateException("Can not visit multi-column path " +
View Full Code Here

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

      else
      {
         ASTPath toPath = (ASTPath) toNode;
         addInnerJoinPath(toPath);
         String toAlias = aliasManager.getAlias(toPath.getPath(toPath.size() - 2));
         JDBCCMPFieldBridge toCMPField = (JDBCCMPFieldBridge) toPath.getCMPField();

         // can only compare like kind entities
         if(!(fromCMPField.getFieldType().equals(toCMPField.getFieldType())))
         {
            throw new IllegalStateException("Only like types can be " +
               "compared: from CMP field=" +
               fromCMPField.getFieldType() +
               " to CMP field=" + toCMPField.getFieldType());
         }

         SQLUtil.getSelfCompareWhereClause(fromCMPField, toCMPField, fromAlias, toAlias, comparison, buf);
      }
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.