Package org.jboss.as.cmp.jdbc.bridge

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


        for (int i = 1; i < path.size(); ++i) {
            String curPath = path.getPath(i);
            final String joinAlias = aliasManager.getAlias(curPath + "_local");

            final JDBCAbstractCMRFieldBridge cmrField = (JDBCAbstractCMRFieldBridge) path.getCMRField(i);
            final JDBCAbstractEntityBridge joinEntity = (JDBCAbstractEntityBridge) cmrField.getRelatedEntity();

            JDBCRelationMetaData relation = cmrField.getMetaData().getRelationMetaData();

            String join = " INNER JOIN ";

            if (relation.isTableMappingStyle()) {
                String relTableAlias = aliasManager.getRelationTableAlias(curPath + "_local");
                sql.append(join)
                        .append(cmrField.getQualifiedTableName())
                        .append(' ')
                        .append(relTableAlias)
                        .append(" ON ");
                SQLUtil.getRelationTableJoinClause(cmrField, leftAlias, relTableAlias, sql);

                sql.append(join)
                        .append(joinEntity.getQualifiedTableName())
                        .append(' ')
                        .append(joinAlias)
                        .append(" ON ");
                SQLUtil.getRelationTableJoinClause(cmrField.getRelatedCMRField(), joinAlias, relTableAlias, sql);
            } else {
                sql.append(join)
                        .append(joinEntity.getQualifiedTableName())
                        .append(' ')
                        .append(joinAlias)
                        .append(" ON ");

                SQLUtil.getJoinClause(cmrField, leftAlias, joinAlias, sql);
View Full Code Here


        Object[] args;
        final ASTPath cntPath = (ASTPath) node.jjtGetChild(0);
        if (cntPath.isCMPField()) {
            args = new Object[]{node.distinct, node.jjtGetChild(0).jjtAccept(this, new StringBuffer()).toString()};
        } else {
            JDBCAbstractEntityBridge entity = (JDBCAbstractEntityBridge) cntPath.getEntity();
            final JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields();
            if (pkFields.length > 1) {
                countCompositePk = true;
                forceDistinct = node.distinct.length() > 0;

                addLeftJoinPath(cntPath);

                String alias = aliasManager.getAlias(cntPath.getPath());
                SQLUtil.getColumnNamesClause(entity.getPrimaryKeyFields(),
                        alias,
                        buf);

                return buf;
            } else {
View Full Code Here

        return data;
    }

    public Object visit(ASTRangeVariableDeclaration node, Object data) {
        ASTAbstractSchema schema = (ASTAbstractSchema) node.jjtGetChild(0);
        JDBCAbstractEntityBridge entity = (JDBCAbstractEntityBridge) schema.entity;
        ASTIdentifier id = (ASTIdentifier) node.jjtGetChild(1);
        declareTable(id.identifier, entity.getQualifiedTableName());
        return data;
    }
View Full Code Here

        }

        ASTPath fromPath = (ASTPath) fromNode;
        addLeftJoinPath(fromPath);
        String fromAlias = aliasManager.getAlias(fromPath.getPath());
        JDBCAbstractEntityBridge fromEntity = (JDBCAbstractEntityBridge) 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 {
            ASTPath toPath = (ASTPath) toNode;
            addLeftJoinPath(toPath);
            String toAlias = aliasManager.getAlias(toPath.getPath());
            JDBCAbstractEntityBridge toEntity = (JDBCAbstractEntityBridge) toPath.getEntity();

            // can only compare like kind entities
            if (!fromEntity.equals(toEntity)) {
                throw CmpMessages.MESSAGES.onlyLikeTypesCanBeCompared(fromEntity.getEntityName(), toEntity.getEntityName());
            }

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

                    final String curPath = path.getPath(i);
                    final String joinAlias = aliasManager.getAlias(curPath);

                    if (joinedAliases.add(joinAlias)) {
                        final JDBCAbstractCMRFieldBridge cmrField = (JDBCAbstractCMRFieldBridge) path.getCMRField(i);
                        final JDBCAbstractEntityBridge joinEntity = (JDBCAbstractEntityBridge) cmrField.getRelatedEntity();

                        JDBCRelationMetaData relation = cmrField.getMetaData().getRelationMetaData();

                        String join = (path.innerJoin ? " INNER JOIN " : " LEFT OUTER JOIN ");

                        if (relation.isTableMappingStyle()) {
                            String relTableAlias = aliasManager.getRelationTableAlias(curPath);
                            sql.append(join)
                                    .append(cmrField.getQualifiedTableName())
                                    .append(' ')
                                    .append(relTableAlias)
                                    .append(" ON ");
                            SQLUtil.getRelationTableJoinClause(cmrField, leftAlias, relTableAlias, sql);

                            sql.append(join)
                                    .append(joinEntity.getQualifiedTableName())
                                    .append(' ')
                                    .append(joinAlias)
                                    .append(" ON ");
                            SQLUtil.getRelationTableJoinClause(cmrField.getRelatedCMRField(), joinAlias, relTableAlias, sql);
                        } else {
                            sql.append(join)
                                    .append(joinEntity.getQualifiedTableName())
                                    .append(' ')
                                    .append(joinAlias)
                                    .append(" ON ");

                            SQLUtil.getJoinClause(cmrField, leftAlias, joinAlias, sql);
View Full Code Here

    public static StringBuffer getJoinClause(JDBCAbstractCMRFieldBridge cmrField,
                                             String parentAlias,
                                             String childAlias,
                                             StringBuffer buf) {
        JDBCAbstractEntityBridge parentEntity = cmrField.getEntity();
        JDBCAbstractEntityBridge childEntity = (JDBCAbstractEntityBridge) cmrField.getRelatedEntity();

        JDBCFieldBridge parentField;
        JDBCFieldBridge childField;

        if (cmrField.hasForeignKey()) {
            // parent has the foreign keys
            JDBCFieldBridge[] parentFkFields = cmrField.getForeignKeyFields();
            int i = 0;
            while (i < parentFkFields.length) {
                parentField = parentFkFields[i++];
                childField = (JDBCFieldBridge) childEntity.getFieldByName(parentField.getFieldName());
                getJoinClause(parentField, parentAlias, childField, childAlias, buf);
                if (i < parentFkFields.length)
                    buf.append(AND);
            }
        } else {
View Full Code Here

    public static StringBuffer getRelationTableJoinClause(JDBCAbstractCMRFieldBridge cmrField,
                                                          String parentAlias,
                                                          String relationTableAlias,
                                                          StringBuffer buf) {
        JDBCAbstractEntityBridge parentEntity = cmrField.getEntity();
        JDBCFieldBridge parentField;
        JDBCFieldBridge relationField;

        // parent to relation table join
        JDBCFieldBridge[] parentFields = cmrField.getTableKeyFields();
        int i = 0;
        while (i < parentFields.length) {
            relationField = parentFields[i++];
            parentField = (JDBCFieldBridge) parentEntity.getFieldByName(relationField.getFieldName());
            getJoinClause(parentField, parentAlias, relationField, relationTableAlias, buf);
            if (i < parentFields.length)
                buf.append(AND);
        }
        return buf;
View Full Code Here

TOP

Related Classes of org.jboss.as.cmp.jdbc.bridge.JDBCAbstractEntityBridge

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.