Package org.jpox.metadata

Examples of org.jpox.metadata.AbstractClassMetaData


        if (fmd == null)
        {
            Iterator iter = managedClassMetaData.iterator();
            while (iter.hasNext())
            {
                AbstractClassMetaData theCmd = (AbstractClassMetaData) iter.next();
                final AbstractMemberMetaData foundFmd = theCmd.getMetaDataForMember(fieldName);
                if (foundFmd != null)
                {
                    if (fmd != null && (!fmd.toString().equalsIgnoreCase(foundFmd.toString()) || fmd.getType() != foundFmd.getType()))
                    {
                        final String errMsg = "Table " + getIdentifier() +
View Full Code Here


        else
        {
            info = new ElementInfo[clsNames.length];
            for (int i=0; i<clsNames.length; i++)
            {
                AbstractClassMetaData cmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(clsNames[i], clr);
                DatastoreClass table = storeMgr.getDatastoreClass(cmd.getFullClassName(), clr);
                info[i] = new ElementInfo(cmd, table);
            }
        }
        return info;
    }
View Full Code Here

                        discrimMapping.setObject(om, ps, Mappings.getParametersIndex(jdbcPosition, discrimMapping), subclass);
                        jdbcPosition += discrimMapping.getNumberOfDatastoreFields();
                    }
                    else if (strategy == DiscriminatorStrategy.VALUE_MAP)
                    {
                        AbstractClassMetaData subclassCmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(subclass, clr);
                        discrimMapping.setObject(om, ps, Mappings.getParametersIndex(jdbcPosition, discrimMapping),
                            subclassCmd.getInheritanceMetaData().getDiscriminatorMetaData().getValue());
                        jdbcPosition += discrimMapping.getNumberOfDatastoreFields();
                    }
                }
            }
        }
View Full Code Here

    {
        StatementExpressionIndex stmtExprIndex = new StatementExpressionIndex();
        //when we have literal values, we don't put the literal in the SQL, but we put the identity columns, so it returns the correct
        //we IGNORE the literal values in the query, and use the literal mapping when the result set is returned
        //here, we just make sure that some columns are added to the SELECT by adding the ID mapping
        AbstractClassMetaData cmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(candidateClass, stmt.getClassLoaderResolver());
        if (cmd.getIdentityType() == IdentityType.DATASTORE)
        {
            stmt.select(storeMgr.getDatastoreClass(candidateClass.getName(), clr).getDataStoreObjectIdMapping(), true);
            stmtExprIndex.setMapping(expr1.getMapping());
        }
        else if (cmd.getIdentityType() == IdentityType.APPLICATION)
        {
            int[] prefetchFieldNumbers = new int[cmd.getPKMemberPositions().length];
            for (int j = 0; j < prefetchFieldNumbers.length; ++j)
            {
                prefetchFieldNumbers[j] = cmd.getPKMemberPositions()[j];
                JavaTypeMapping m = storeMgr.getDatastoreClass(candidateClass.getName(), clr).getFieldMapping(
                    cmd.getMetaDataForManagedMemberAtAbsolutePosition(prefetchFieldNumbers[j]));
                if (m != null) // field is not stored in the table, e.g List, Set, etc or is transactional
                {
                    if (m.includeInFetchStatement() && !(m instanceof AbstractContainerMapping))
                    {
                        stmt.select(m, true);
View Full Code Here

                        // 1-N uni/bidirectional using FK, so update the element side with a FK
                        if ((fmd.getCollection() != null && !SCOUtils.collectionHasSerialisedElements(fmd)) ||
                            (fmd.getArray() != null && !SCOUtils.arrayIsStoredInSingleColumn(fmd)))
                        {
                            // 1-N ForeignKey collection/array, so add FK to element table
                            AbstractClassMetaData elementCmd = null;
                            if (fmd.hasCollection())
                            {
                                // Collection
                                elementCmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(fmd.getCollection().getElementType(), clr);
                            }
                            else
                            {
                                // Array
                                elementCmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(fmd.getType().getComponentType(), clr);
                            }
                            if (elementCmd == null)
                            {
                                // Elements that are reference types or non-PC will come through here
                                if (fmd.hasCollection())
                                {
                                    JPOXLogger.METADATA.warn(LOCALISER.msg("057016",
                                        theCmd.getFullClassName(), fmd.getCollection().getElementType()));
                                }
                                else
                                {
                                    JPOXLogger.METADATA.warn(LOCALISER.msg("057014",
                                        theCmd.getFullClassName(), fmd.getType().getComponentType().getName()));
                                }
                            }
                            else
                            {
                                AbstractClassMetaData[] elementCmds = null;
                                // TODO : Cater for interface elements, and get the metadata for the implementation classes here
                                if (elementCmd.getInheritanceMetaData().getStrategyValue() == InheritanceStrategy.SUBCLASS_TABLE)
                                {
                                    elementCmds = storeMgr.getClassesManagingTableForClass(elementCmd, clr);
                                }
                                else
                                {
                                    elementCmds = new ClassMetaData[1];
                                    elementCmds[0] = elementCmd;
                                }

                                // Run callbacks for each of the element classes.
                                for (int i=0;i<elementCmds.length;i++)
                                {
                                    callbacks.put(elementCmds[i].getFullClassName(), new CallBack(fmd));
                                    DatastoreClass dc = storeMgr.getDatastoreClass(elementCmds[i].getFullClassName(), clr);
                                    ClassTable ct = (ClassTable) dc;
                                    if (ct.isInitialized())
                                    {
                                        // if the target table is already initialized, run the callbacks
                                        ct.runCallBacks(clr);
                                    }
                                }
                            }
                        }
                        else if (fmd.getMap() != null && !SCOUtils.mapHasSerialisedKeysAndValues(fmd))
                        {
                            // 1-N ForeignKey map, so add FK to value table
                            if (fmd.getKeyMetaData() != null && fmd.getKeyMetaData().getMappedBy() != null)
                            {
                                // Key is stored in the value table so add the FK to the value table
                                AbstractClassMetaData valueCmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(fmd.getMap().getValueType(), clr);
                                if (valueCmd == null)
                                {
                                    // Interface elements will come through here and java.lang.String and others as well
                                    JPOXLogger.METADATA.warn(LOCALISER.msg("057018",
                                        theCmd.getFullClassName(), fmd.getMap().getValueType()));
                                }
                                else
                                {
                                    AbstractClassMetaData[] valueCmds = null;
                                    // TODO : Cater for interface values, and get the metadata for the implementation classes here
                                    if (valueCmd.getInheritanceMetaData().getStrategyValue() == InheritanceStrategy.SUBCLASS_TABLE)
                                    {
                                        valueCmds = storeMgr.getClassesManagingTableForClass(valueCmd, clr);
                                    }
                                    else
                                    {
                                        valueCmds = new ClassMetaData[1];
                                        valueCmds[0] = valueCmd;
                                    }
                                   
                                    // Run callbacks for each of the value classes.
                                    for (int i=0;i<valueCmds.length;i++)
                                    {
                                        callbacks.put(valueCmds[i].getFullClassName(), new CallBack(fmd));
                                        DatastoreClass dc = storeMgr.getDatastoreClass(valueCmds[i].getFullClassName(), clr);
                                        ClassTable ct = (ClassTable) dc;
                                        if (ct.isInitialized())
                                        {
                                            // if the target table is already initialized, run the callbacks
                                            ct.runCallBacks(clr);
                                        }
                                    }
                                }
                            }
                            else if (fmd.getValueMetaData() != null && fmd.getValueMetaData().getMappedBy() != null)
                            {
                                // Value is stored in the key table so add the FK to the key table
                                AbstractClassMetaData keyCmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(fmd.getMap().getKeyType(), clr);
                                if (keyCmd == null)
                                {
                                    // Interface elements will come through here and java.lang.String and others as well
                                    JPOXLogger.METADATA.warn(LOCALISER.msg("057019",
                                        theCmd.getFullClassName(), fmd.getMap().getKeyType()));
                                }
                                else
                                {
                                    AbstractClassMetaData[] keyCmds = null;
                                    // TODO : Cater for interface keys, and get the metadata for the implementation classes here
                                    if (keyCmd.getInheritanceMetaData().getStrategyValue() == InheritanceStrategy.SUBCLASS_TABLE)
                                    {
                                        keyCmds = storeMgr.getClassesManagingTableForClass(keyCmd, clr);
                                    }
                                    else
                                    {
View Full Code Here

            Class cls = (subqueryCandidateExprRootAliasInfo != null ?
                    subqueryCandidateExprRootAliasInfo.cls : parentExpr.getCandidateClass());
            ClassLoaderResolver clr = query.getObjectManager().getClassLoaderResolver();
            MetaDataManager mmgr = query.getObjectManager().getMetaDataManager();
            MappedStoreManager storeMgr = (MappedStoreManager)query.getStoreManager();
            AbstractClassMetaData leftCmd = mmgr.getMetaDataForClass(cls, clr);
            LogicSetExpression leftTblExpr = (subqueryCandidateExprRootAliasInfo != null ?
                    subqueryCandidateExprRootAliasInfo.tableExpression : parentExpr.getMainTableExpression());
            String leftAlias = (subqueryCandidateExprRootAliasInfo != null ?
                    subqueryCandidateExprRootAliasInfo.alias : parentExpr.getCandidateAlias());
            DatastoreClass leftTable = (DatastoreClass)leftTblExpr.getMainTable();
            for (int i=1;i<tokens.length;i++)
            {
                // Process the join from the previous token to this token
                AbstractMemberMetaData leftMmd = leftCmd.getMetaDataForMember(tokens[i]);
                AbstractClassMetaData rightCmd = null;
                int relationType = leftMmd.getRelationType(clr);
                AbstractMemberMetaData rightMmd = null;
                if (relationType == Relation.ONE_TO_ONE_BI || relationType == Relation.ONE_TO_MANY_BI ||
                    relationType == Relation.MANY_TO_MANY_BI || relationType == Relation.MANY_TO_ONE_BI)
                {
View Full Code Here

        {
            // FCO candidates
            if (candidateTable == null)
            {
                // Candidate class has no table! so see if it has one subclass (with table) only and use that
                AbstractClassMetaData acmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(candidateFullClassName, clr);
                AbstractClassMetaData subclassCmds[] = storeMgr.getClassesManagingTableForClass(acmd, clr);
                if (subclassCmds != null && subclassCmds.length == 1)
                {
                    // Candidate uses "subclass-table" and only one subclass
                    candidateTable = storeMgr.getDatastoreClass(subclassCmds[0].getFullClassName(), clr);
                    candidateFullClassName = subclassCmds[0].getFullClassName();
View Full Code Here

            // Restrict to valid discriminator values where we have a discriminator specified on this table
            String discriminatorValue = targetElementType;
            if (discriminatorMetaData.getStrategy() == DiscriminatorStrategy.VALUE_MAP)
            {
                // Get the MetaData for the target class since that holds the "value"
                AbstractClassMetaData targetCmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(targetElementType, clr);
                discriminatorValue = targetCmd.getInheritanceMetaData().getDiscriminatorMetaData().getValue();
            }
            ScalarExpression discrExpr = discriminatorMapping.newScalarExpression(stmt, discriminatorTableExpr);
            ScalarExpression discrVal = discriminatorMapping.newLiteral(stmt, discriminatorValue);
            stmt.andCondition(discrExpr.eq(discrVal));
        }
View Full Code Here

            ScalarExpression targetSubElementTypeExpr;

            DatastoreClass[] targetSubElementTypes = null;
            if (cbtTargetSubElementType == null)
            {
                AbstractClassMetaData targetSubCmd =
                    storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(targetSubElementType, stmt.getClassLoaderResolver());
                AbstractClassMetaData[] targetSubCmds = storeMgr.getClassesManagingTableForClass(targetSubCmd, clr);
                targetSubElementTypes = new DatastoreClass[targetSubCmds.length];
                for (int i=0;i<targetSubCmds.length;i++)
                {
View Full Code Here

        // Default to the "class-name" discriminator strategy
        String discriminatorValue = className;
        if (dismd.getStrategy() == DiscriminatorStrategy.VALUE_MAP)
        {
            // Get the MetaData for the target class since that holds the "value"
            AbstractClassMetaData targetCmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(className, stmt.getClassLoaderResolver());
            discriminatorValue = targetCmd.getInheritanceMetaData().getDiscriminatorMetaData().getValue();
        }
        ScalarExpression discrExpr = discriminatorMapping.newScalarExpression(stmt, discrimTableExpr);
        ScalarExpression discrVal = discriminatorMapping.newLiteral(stmt, discriminatorValue);
        stmt.iorCondition(discrExpr.eq(discrVal));
    }
View Full Code Here

TOP

Related Classes of org.jpox.metadata.AbstractClassMetaData

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.