Package org.jpox.store.rdbms.table

Examples of org.jpox.store.rdbms.table.CollectionTable


        {
            DatastoreIdentifier tableName = getTableIdentifier(fmd, clr);
            DatastoreContainerObject join = null;
            if (type == JOIN_TABLE_COLLECTION)
            {
                join = new CollectionTable(tableName, fmd, RDBMSManager.this);
            }
            else if (type == JOIN_TABLE_MAP)
            {
                join = new MapTable(tableName, fmd, RDBMSManager.this);
            }
View Full Code Here


            }
            else
            {
                if (t instanceof CollectionTable)
                {
                    CollectionTable collTable = (CollectionTable) t;
                    if (im.subfieldName.equals("owner"))
                    {
                        m = collTable.getOwnerMapping();
                    }
                    else if (im.subfieldName.equals("element"))
                    {
                        m = collTable.getElementMapping();
                    }
                    else if (im.subfieldName.equals("index"))
                    {
                        m = collTable.getOrderMapping();
                    }
                    else
                    {
                        throw new JPOXUserException(LOCALISER_RDBMS.msg(
                            "050036", im.subfieldName, im));
View Full Code Here

                    ScalarExpression leftCentreExpr = null;
                    ScalarExpression rightCentreExpr = null;
                    LogicSetExpression joinTblExpr = null;
                    if (leftMmd.hasCollection())
                    {
                        CollectionTable joinTbl = (CollectionTable)storeMgr.getDatastoreContainerObject(leftMmd);
                        DatastoreIdentifier joinTblAlias = storeMgr.getIdentifierFactory().newIdentifier(
                            IdentifierFactory.TABLE, leftAlias + "." + rightAlias);
                        joinTblExpr = qs.newTableExpression(joinTbl, joinTblAlias);
                        leftCentreExpr = joinTbl.getOwnerMapping().newScalarExpression(qs, joinTblExpr);
                        rightCentreExpr = joinTbl.getElementMapping().newScalarExpression(qs, joinTblExpr);
                    }
                    else if (leftMmd.hasMap())
                    {
                        MapTable joinTbl = (MapTable)storeMgr.getDatastoreContainerObject(leftMmd);
                        DatastoreIdentifier joinTblAlias = storeMgr.getIdentifierFactory().newIdentifier(
                            IdentifierFactory.TABLE, leftAlias + "." + rightAlias);
                        joinTblExpr = qs.newTableExpression(joinTbl, joinTblAlias);
                        leftCentreExpr = joinTbl.getOwnerMapping().newScalarExpression(qs, joinTblExpr);
                        rightCentreExpr = joinTbl.getValueMapping().newScalarExpression(qs, joinTblExpr);
                    }

                    if (i == 1)
                    {
                        // And condition to outer candidate
                        qs.andCondition(leftExpr.eq(leftCentreExpr), true);
                    }
                    else
                    {
                        // Inner join to table
                        qs.innerJoin(leftCentreExpr, leftExpr, leftTblExpr, true, true);
                    }
                    qs.innerJoin(rightExpr, rightCentreExpr, joinTblExpr, true, true);
                }
                else if ((relationType == Relation.ONE_TO_MANY_BI &&
                    (leftMmd.getJoinMetaData() != null || rightMmd.getJoinMetaData() != null)) ||
                    (relationType == Relation.MANY_TO_ONE_BI &&
                     (leftMmd.getJoinMetaData() != null || rightMmd.getJoinMetaData() != null)) ||
                     relationType == Relation.MANY_TO_MANY_BI)
                {
                    // 1-N/N-1 bi JoinTable
                    ScalarExpression leftExpr = leftTable.getIDMapping().newScalarExpression(qs, leftTblExpr);
                    ScalarExpression rightExpr = rightTable.getIDMapping().newScalarExpression(qs, rightTblExpr);
                    ScalarExpression leftCentreExpr = null;
                    ScalarExpression rightCentreExpr = null;
                    LogicSetExpression joinTblExpr = null;
                    if (leftMmd.hasCollection() || rightMmd.hasCollection())
                    {
                        CollectionTable joinTbl = (CollectionTable)storeMgr.getDatastoreContainerObject(leftMmd);
                        DatastoreIdentifier joinTblAlias = storeMgr.getIdentifierFactory().newIdentifier(
                            IdentifierFactory.TABLE, leftAlias + "." + rightAlias);
                        joinTblExpr = qs.newTableExpression(joinTbl, joinTblAlias);
                        leftCentreExpr = joinTbl.getOwnerMapping().newScalarExpression(qs, joinTblExpr);
                        rightCentreExpr = joinTbl.getElementMapping().newScalarExpression(qs, joinTblExpr);
                    }
                    else if (leftMmd.hasMap() || rightMmd.hasMap())
                    {
                        MapTable joinTbl = (MapTable)storeMgr.getDatastoreContainerObject(leftMmd);
                        DatastoreIdentifier joinTblAlias = storeMgr.getIdentifierFactory().newIdentifier(
                            IdentifierFactory.TABLE, leftAlias + "." + rightAlias);
                        joinTblExpr = qs.newTableExpression(joinTbl, joinTblAlias);
                        leftCentreExpr = joinTbl.getOwnerMapping().newScalarExpression(qs, joinTblExpr);
                        rightCentreExpr = joinTbl.getValueMapping().newScalarExpression(qs, joinTblExpr);
                    }

                    if (i == 1)
                    {
                        // And condition to outer candidate
View Full Code Here

                            // Join Table N-1 [join left[ID]->centre(ID_FK), centre(ID_OWN)->right[ID])
                            ScalarExpression leftExpr =
                                leftTable.getIDMapping().newScalarExpression(qs, leftTableExpr);
                            ScalarExpression rightExpr =
                                rightTable.getIDMapping().newScalarExpression(qs, rightTblExpr);
                            CollectionTable joinTbl = (CollectionTable)srm.getDatastoreContainerObject(rightMmd);
                            String joinTblIdName = rightTblIdName + "." + leftAlias;
                            DatastoreIdentifier joinTblId =
                                srm.getIdentifierFactory().newIdentifier(IdentifierFactory.TABLE, joinTblIdName);
                            LogicSetExpression joinTblExpr = qs.newTableExpression(joinTbl, joinTblId);
                            ScalarExpression joinLeftExpr =
                                joinTbl.getElementMapping().newScalarExpression(qs, joinTblExpr);
                            ScalarExpression joinRightExpr =
                                joinTbl.getOwnerMapping().newScalarExpression(qs, joinTblExpr);
                            if (joinExpr.isLeftJoin())
                            {
                                qs.leftOuterJoin(leftExpr, joinLeftExpr, joinTblExpr, true, true);
                                qs.innerJoin(joinRightExpr, rightExpr, rightTblExpr, true, true);
                            }
                            else
                            {
                                qs.innerJoin(leftExpr, joinLeftExpr, joinTblExpr, true, true);
                                qs.innerJoin(joinRightExpr, rightExpr, rightTblExpr, true, true);
                            }
                        }
                        else
                        {
                            // FK N-1 [join left[FK]->right[ID])
                            ScalarExpression leftExpr = leftTableExpr.newFieldExpression(leftMmd.getName());
                            ScalarExpression rightExpr = rightTable.getIDMapping().newScalarExpression(qs, rightTblExpr);
                            if (joinExpr.isLeftJoin())
                            {
                                qs.leftOuterJoin(leftExpr, rightExpr, rightTblExpr, true, true);
                            }
                            else
                            {
                                qs.innerJoin(leftExpr, rightExpr, rightTblExpr, true, true);
                            }
                        }
                    }
                    if (joinExpr.getAlias() != null)
                    {
                        AliasJoinInformation rightAliasInfo = new AliasJoinInformation(joinExpr.getAlias().toUpperCase(),
                            leftMmd.getType(), rightTblExpr, false);
                        aliases.put(rightAliasInfo.alias, rightAliasInfo);
                    }
                }
                else if (leftMapping instanceof CollectionMapping)
                {
                    // 1-N, M-N collection (element) field
                    DatastoreClass rightTable =
                        srm.getDatastoreClass(leftMmd.getCollection().getElementType(), clr);
                    LogicSetExpression rightTblExpr = qs.newTableExpression(rightTable, rightTblId);
                    if (relationType == Relation.MANY_TO_MANY_BI || leftMmd.getJoinMetaData() != null)
                    {
                        // TODO Cater for 1-N with join specified at other side
                        // 1-N uni/bi JoinTable relation [join left[ID]->centre(ID_OWN), centre(ID_FK)->right[ID])
                        ScalarExpression leftExpr =
                            leftTable.getIDMapping().newScalarExpression(qs, leftTableExpr);
                        ScalarExpression rightExpr =
                            rightTable.getIDMapping().newScalarExpression(qs, rightTblExpr);
                        CollectionTable joinTbl = (CollectionTable)srm.getDatastoreContainerObject(leftMmd);
                        String joinTblIdName = leftAlias + "." + rightTblIdName;
                        DatastoreIdentifier joinTblId =
                            srm.getIdentifierFactory().newIdentifier(IdentifierFactory.TABLE, joinTblIdName);
                        LogicSetExpression joinTblExpr = qs.newTableExpression(joinTbl, joinTblId);
                        ScalarExpression joinLeftExpr =
                            joinTbl.getOwnerMapping().newScalarExpression(qs, joinTblExpr);
                        ScalarExpression joinRightExpr =
                            joinTbl.getElementMapping().newScalarExpression(qs, joinTblExpr);
                        if (joinExpr.isLeftJoin())
                        {
                            qs.leftOuterJoin(leftExpr, joinLeftExpr, joinTblExpr, true, true);
                            qs.innerJoin(joinRightExpr, rightExpr, rightTblExpr, true, true);
                        }
View Full Code Here

                            {
                                JavaTypeMapping referenceMapping = null;
                                JavaTypeMapping selectMapping = null;
                                if (java.util.Collection.class.isAssignableFrom(relatedMmds[0].getType()))
                                {
                                    CollectionTable collTable = (CollectionTable)joinTable;
                                    referenceMapping = collTable.getElementMapping();
                                    selectMapping = collTable.getOwnerMapping();
                                }

                                // TODO Do we need to allow for a discriminator in the owner class here ?
                                // TODO Do we need to allow for subclass table here (like in 1-1 case) ?
                                expressionsIndex = fetchStmt.selectOuterJoin(referenceMapping, selectMapping,
View Full Code Here

TOP

Related Classes of org.jpox.store.rdbms.table.CollectionTable

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.