Package org.jpox.store.mapped

Examples of org.jpox.store.mapped.DatastoreIdentifier


            {
                String castTypeName = castType.getName();
                jtIdentifier = idFactory.newIdentifier(this.te.getAlias(), castTypeName.substring(castTypeName.lastIndexOf('.') + 1)).getIdentifier();
            }

            DatastoreIdentifier jtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, jtIdentifier);
            LogicSetExpression jtTblExpr = qs.getTableExpression(jtRangeVar);

            if (jtTblExpr == null)
            {
                jtTblExpr = qs.newTableExpression(dc, jtRangeVar);
View Full Code Here


        {
            String castTypeName = castType.getName();
            jtIdentifier += '.' + castTypeName.substring(castTypeName.lastIndexOf('.') + 1);
        }

        DatastoreIdentifier jtRangeVar = qs.getStoreManager().getIdentifierFactory().newIdentifier(IdentifierFactory.TABLE, jtIdentifier);
        LogicSetExpression jtTblExpr = qs.getTableExpression(jtRangeVar);
        if (jtTblExpr == null)
        {
            // We can't join further (this subfield is not an object with a table expression)
            if (te.getAlias().getIdentifier().equalsIgnoreCase("this") && // TODO Use qs.getCandidateAlias()
View Full Code Here

                else
                {
                    // Using field, so our real table will have an identifier of "THIS_{fieldName}" via INNER JOIN
                    String fieldIdentifier = te.getAlias().getIdentifier();
                    fieldIdentifier += '.' + fieldName;
                    DatastoreIdentifier fieldRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, fieldIdentifier);
                    fieldTblExpr = qs.getTableExpression(fieldRangeVar);
                    if (fieldTblExpr == null)
                    {
                        fieldTblExpr = qs.newTableExpression(table, fieldRangeVar);
                    }
                    ScalarExpression fieldExpr = table.getIDMapping().newScalarExpression(qs, fieldTblExpr);
                    expr = mapping.newScalarExpression(qs, te);
                    qs.innerJoin(fieldExpr, expr, fieldTblExpr, true, true);
                }

                // Return a constraint on the discriminator for this table to get the right instances
                // This allows all discriminator values for the instanceof class and all of its subclasses
                // DISCRIM = 'baseVal' OR DISCRIM = 'sub1Val' OR DISCRIM = 'sub2Val' ... etc
                BooleanExpression discrExpr =
                    booleanConditionForClassInDiscriminator(qs, instanceofClass.getName(), dismd,
                        discriminatorMapping, fieldTblExpr);
                Iterator subclassIter = qs.getStoreManager().getSubClassesForClass(instanceofClass.getName(),
                    true, clr).iterator();
                while (subclassIter.hasNext())
                {
                    String subCandidateType = (String)subclassIter.next();
                    discrExpr.ior(booleanConditionForClassInDiscriminator(qs, subCandidateType, dismd,
                        discriminatorMapping, fieldTblExpr));
                }
                discrExpr.encloseWithInParentheses();

                return discrExpr;
            }
            else
            {
                // No discriminator so maybe union, or just a SELECT
                // Need to join to the instanceof class (where appropriate)
                // TODO RDBMS-71 Only join on the UNION select that it is applicable to
                if (table instanceof DatastoreClass)
                {
                    DatastoreClass ct = (DatastoreClass)table;
                    if (ct.managesClass(instanceofClass.getName()))
                    {
                        // This type is managed in this table so must be an instance
                        return new BooleanLiteral(qs, mapping, true).eq(new BooleanLiteral(qs, mapping, true));
                    }
                    else
                    {
                        // The instanceof type is not managed here
                        DatastoreClass instanceofTable = qs.getStoreManager().getDatastoreClass(
                            instanceofClass.getName(), clr);
                        String fieldIdentifier = te.getAlias().getIdentifier();
                        if (fieldName == null)
                        {
                            // Using THIS, so our real table will have an identifier of "THIS_INST"
                            fieldIdentifier += ".INST";
                        }
                        else
                        {
                            // Using field, so our real table will have an identifier of "THIS_{fieldName}"
                            fieldIdentifier += '.' + fieldName;
                        }
                        DatastoreIdentifier fieldRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, fieldIdentifier);
                        LogicSetExpression fieldTblExpr = qs.newTableExpression(instanceofTable, fieldRangeVar);
                        ScalarExpression fieldExpr = table.getIDMapping().newScalarExpression(qs, te);
                        if (fieldName == null)
                        {
                            expr = instanceofTable.getIDMapping().newScalarExpression(qs, fieldTblExpr);
View Full Code Here

    public String toString()
    {
        if (sqlText == null)
        {
            StringBuffer sb = new StringBuffer();
            DatastoreIdentifier mainTableName = mainTable.getIdentifier();

            if (!multipleTablesReferenced)
            {
                sb.append(mainTable.toString());
                if (!mainAlias.equals(mainTableName))
View Full Code Here

                DatastoreClass targetTable = srm.getDatastoreClass(fmd.getTypeName(), clr);
                AbstractMemberMetaData[] relatedMmds = fmd.getRelatedMemberMetaData(clr);
                // TODO Cater for more than one related field
                JavaTypeMapping refMapping = targetTable.getFieldMapping(relatedMmds[0]);
                JavaTypeMapping selectMapping = targetTable.getIDMapping();
                DatastoreIdentifier targetTableIdentifier =
                    srm.getIdentifierFactory().newIdentifier(IdentifierFactory.TABLE, "RELATED" + fmd.getAbsoluteFieldNumber());
                LogicSetExpression targetTe = qs.newTableExpression(targetTable, targetTableIdentifier);
                return new ObjectExpression(qs, this, te, refMapping, targetTe, selectMapping);
            }
            else if (relationType == Relation.MANY_TO_ONE_BI)
            {
                AbstractMemberMetaData[] relatedMmds = fmd.getRelatedMemberMetaData(clr);
                // TODO Cater for more than one related field
                if (fmd.getJoinMetaData() != null || relatedMmds[0].getJoinMetaData() != null)
                {
                    // Join table relation - only allows for Collection/Array
                    // Create an expression this table to the join table on the element id, selecting the owner id
                    DatastoreContainerObject targetTable = srm.getDatastoreContainerObject(relatedMmds[0]);
                    JavaTypeMapping refMapping = null;
                    JavaTypeMapping selectMapping = null;
                    DatastoreElementContainer elementTable = (DatastoreElementContainer)targetTable;
                    refMapping = elementTable.getElementMapping();
                    selectMapping = elementTable.getOwnerMapping();
                    DatastoreIdentifier targetTableIdentifier =
                        srm.getIdentifierFactory().newIdentifier(IdentifierFactory.TABLE, "JOINTABLE" + fmd.getAbsoluteFieldNumber());
                    LogicSetExpression targetTe = qs.newTableExpression(targetTable, targetTableIdentifier);
                    return new ObjectExpression(qs, this, te, refMapping, targetTe, selectMapping);
                }
            }
View Full Code Here

                    else if (imd.getStrategyValue() == InheritanceStrategy.NEW_TABLE ||
                             imd.getStrategyValue() == InheritanceStrategy.COMPLETE_TABLE)
                    {
                        // Table managed by this class
                        // Generate an identifier for the table required
                        DatastoreIdentifier tableName = getTableIdentifier(cmd, clr);

                        // Check that the required table isn't already in use
                        StoreData[] existingStoreData = getStoreDataForDatastoreContainerObject(tableName);
                        if (existingStoreData != null)
                        {
                            String existingClass = null;
                            for (int j=0;j<existingStoreData.length;j++)
                            {
                                if (!existingStoreData[j].getName().equals(cmd.getFullClassName()))
                                {
                                    existingClass = existingStoreData[j].getName();
                                    break;
                                }
                            }
                            // Give a warning and then create a new instance of the table (mapped to the same datastore object)
                            if (existingClass != null)
                            {
                                String msg = LOCALISER_RDBMS.msg("050015", cmd.getFullClassName(),
                                    tableName.getIdentifier(), existingClass);
                                JPOXLogger.DATASTORE.warn(msg);
                            }
                        }

                        // Create the table to use for this class
View Full Code Here

         * @param fmd The field metadata describing the Array field.
         * @param type The type of the join table
         */
        private DatastoreContainerObject addJoinTableForContainer(AbstractMemberMetaData fmd, ClassLoaderResolver clr, int type)
        {
            DatastoreIdentifier tableName = getTableIdentifier(fmd, clr);
            DatastoreContainerObject join = null;
            if (type == JOIN_TABLE_COLLECTION)
            {
                join = new CollectionTable(tableName, fmd, RDBMSManager.this);
            }
View Full Code Here

                // No need to LEFT OUTER JOIN for "subclass-table" and "superclass-table" cases
                // "subclass-table" objects dont exist on their own
                // "superclass-table" are excluded using the discriminator clause
                if (subclassTable != null && !subclassTable.getIdentifier().equals(schemaDataOption.getDatastoreContainerObject().getIdentifier()))
                {
                    DatastoreIdentifier subclassTableIdentifier = storeMgr.getIdentifierFactory().newIdentifier(IdentifierFactory.TABLE, "SUBCLASS" + (subclasses_seq_id++));
                    QueryExpression st = storeMgr.getDatastoreAdapter().newQueryStatement(subclassTable, subclassTableIdentifier, om.getClassLoaderResolver());
                    LogicSetExpression table_expr_sub = st.newTableExpression(subclassTable, subclassTableIdentifier);
                    JavaTypeMapping subMapping = subclassTable.getIDMapping();
                    st.select(subclassTableIdentifier, subMapping);
View Full Code Here

     * has the effect of a reload of the tables information the next time it is needed.
     * @param table The table
     */
    public void invalidateColumnInfoForTable(Table table)
    {
        DatastoreIdentifier tableId = ((AbstractTable)table).getDatastoreIdentifierFullyQualified();
        columnInfoByTableName.remove(tableId);
    }
View Full Code Here

     * @return The DatastoreIdentifier
     */
    public DatastoreIdentifier newDatastoreFieldIdentifier(String identifierName)
    {
        String key = JDBCUtils.getIdentifierNameStripped(identifierName, dba); // Allow for quotes on input names
        DatastoreIdentifier identifier = (DatastoreIdentifier) columns.get(key);
        if (identifier == null)
        {
            String baseID = truncate(key, getMaxLengthForIdentifierType(IdentifierFactory.COLUMN));
            identifier = new ColumnIdentifier(this, baseID);
            columns.put(key, identifier);
View Full Code Here

TOP

Related Classes of org.jpox.store.mapped.DatastoreIdentifier

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.