Examples of MappedStoreManager


Examples of org.jpox.store.mapped.MappedStoreManager

            }
            else
            {
                acmd = datastoreContainer.getStoreManager().getOMFContext().getMetaDataManager().getMetaDataForClass(fmd.getType(), clr);
            }
            MappedStoreManager storeMgr = datastoreContainer.getStoreManager();
            TypeManager typeMgr = storeMgr.getOMFContext().getTypeManager();

            if (fmd.isSerialized())
            {
                // Field is marked as serialised then we have no other option - serialise it
                mc = getMappingClass(fmd.getType(), true, false, fmd.getFullFieldName(),
                    typeMgr, storeMgr.getApiAdapter());
            }
            else if (fmd.getEmbeddedMetaData() != null)
            {
                // Field has an <embedded> specification so use that
                mc = getMappingClass(fmd.getType(), false, true, fmd.getFullFieldName(),
                    typeMgr, storeMgr.getApiAdapter());
            }
            else if (acmd != null && acmd.isEmbeddedOnly())
            {
                // If the reference type is declared with embedded only
                mc = getMappingClass(fmd.getType(), false, true, fmd.getFullFieldName(),
                    typeMgr, storeMgr.getApiAdapter());
            }
            else if (fmd.isEmbedded())
            {
                // Otherwise, if the field is embedded then we request that it be serialised into the owner table
                // This is particularly for java.lang.Object which should be "embedded" by default, and hence serialised
                mc = getMappingClass(fmd.getType(), true, false, fmd.getFullFieldName(),
                    typeMgr, storeMgr.getApiAdapter());
            }
            else
            {
                // Just get the basic mapping for the type
                mc = getMappingClass(fmd.getType(), false, false, fmd.getFullFieldName(),
                    typeMgr, storeMgr.getApiAdapter());
            }
        }
        mc = getOverrideMappingClass(mc, fmd, roleForField); // Allow for overriding in subclasses

        // Create the mapping of the selected type
View Full Code Here

Examples of org.jpox.store.mapped.MappedStoreManager

     * @param clr The ClassLoaderResolver
     */
    protected void prepareDatastoreMapping(ClassLoaderResolver clr)
    {
        // Either one end of a 1-1 relation, or the N end of a N-1
        MappedStoreManager storeMgr = datastoreContainer.getStoreManager();
        AbstractClassMetaData refCmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(fmd.getType(), clr);
        JavaTypeMapping referenceMapping = null;
        if (refCmd.getInheritanceMetaData().getStrategyValue() == InheritanceStrategy.SUBCLASS_TABLE)
        {
            // Find the actual tables storing the other end (can be multiple subclasses)
            AbstractClassMetaData[] cmds = storeMgr.getClassesManagingTableForClass(refCmd, clr);
            if (cmds != null && cmds.length > 0)
            {
                if (cmds.length > 1)
                {
                    JPOXLogger.PERSISTENCE.warn("Field " + fmd.getFullFieldName() + " represents either a 1-1 relation, " +
                        "or a N-1 relation where the other end uses \"subclass-table\" inheritance strategy and more " +
                        "than 1 subclasses with a table. This is not fully supported by JPOX");
                }
            }
            else
            {
                // No subclasses of the class using "subclasses-table" so no mapping!
                // TODO Throw an exception ?
                return;
            }
            // TODO We need a mapping for each of the possible subclass tables
            referenceMapping = storeMgr.getDatastoreClass(cmds[0].getFullClassName(), clr).getIDMapping();
        }
        else
        {
            referenceMapping = storeMgr.getDatastoreClass(fmd.getType().getName(), clr).getIDMapping();
        }

        // Generate a mapping from the columns of the referenced object to this mapping's ColumnMetaData
        CorrespondentColumnsMapper correspondentColumnsMapping = new CorrespondentColumnsMapper(fmd, referenceMapping, true);

View Full Code Here

Examples of org.jpox.store.mapped.MappedStoreManager

            return new ObjectExpression(qs, this, te);
        }
        else
        {
            ClassLoaderResolver clr = qs.getClassLoaderResolver();
            MappedStoreManager srm = qs.getStoreManager();
            int relationType = fmd.getRelationType(clr);
            if (relationType == Relation.ONE_TO_ONE_BI)
            {
                // Create an expression joining to the related field in the related table
                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

Examples of org.jpox.store.mapped.MappedStoreManager

            for (int i=0; i<cmd.getPKMemberPositions().length; ++i)
            {
                AbstractMemberMetaData fmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(cmd.getPKMemberPositions()[i]);
                Field field = objectIdClass.getField(fmd.getName());

                MappedStoreManager storeMgr = (MappedStoreManager)om.getStoreManager();
                JavaTypeMapping m = storeMgr.getDatastoreClass(cmd.getFullClassName(), om.getClassLoaderResolver()).getFieldMapping(fmd);
                // NOTE This assumes that each field has one datastore column.
                for (int j = 0; j < m.getNumberOfDatastoreFields(); j++)
                {
                    // TODO Factor this out - using RDBMS-specific code
                    Object obj = ((ResultSet)rs).getObject(param[paramIndex++]);
View Full Code Here

Examples of org.jpox.store.mapped.MappedStoreManager

        // Concrete class
        int totalFieldCount = cmd.getNoOfManagedMembers() + cmd.getNoOfInheritedManagedMembers();
        final StatementExpressionIndex[] statementExpressionIndex = new StatementExpressionIndex[totalFieldCount];
        int paramIndex = 0;

        final MappedStoreManager storeMgr = (MappedStoreManager)om.getStoreManager();
        DatastoreClass datastoreClass = storeMgr.getDatastoreClass(cmd.getFullClassName(), clr);
        final int[] pkFieldNumbers = cmd.getPKMemberPositions();

        for (int i=0; i<pkFieldNumbers.length; ++i)
        {
            AbstractMemberMetaData fmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(pkFieldNumbers[i]);
            JavaTypeMapping m = datastoreClass.getFieldMapping(fmd);
            statementExpressionIndex[fmd.getAbsoluteFieldNumber()] = new StatementExpressionIndex();
            statementExpressionIndex[fmd.getAbsoluteFieldNumber()].setMapping(m);
            int expressionsIndex[] = new int[m.getNumberOfDatastoreFields()];
            for (int j = 0; j < expressionsIndex.length; j++)
            {
                expressionsIndex[j] = param[paramIndex++];
            }
            statementExpressionIndex[fmd.getAbsoluteFieldNumber()].setExpressionIndex(expressionsIndex);
        }

        return om.findObjectUsingAID(clr.classForName(cmd.getFullClassName()),
            new FieldValues()
            {
            // StateManager calls the fetchFields method
            public void fetchFields(StateManager sm)
            {
                sm.replaceFields(pkFieldNumbers,
                    storeMgr.getFieldManagerForResultProcessing(sm, rs, statementExpressionIndex));
            }
            public void fetchNonLoadedFields(StateManager sm)
            {
                sm.replaceNonLoadedFields(pkFieldNumbers,
                    storeMgr.getFieldManagerForResultProcessing(sm, rs, statementExpressionIndex));
            }
            public FetchPlan getFetchPlanForLoading()
            {
                return null;
            }
View Full Code Here

Examples of org.jpox.store.mapped.MappedStoreManager

            return;
        }

        // Check if the field has a FK defined
        ClassLoaderResolver clr = sm.getObjectManager().getClassLoaderResolver();
        MappedStoreManager storeMgr = (MappedStoreManager)sm.getObjectManager().getStoreManager();
        AbstractMemberMetaData[] relatedMmds = fmd.getRelatedMemberMetaData(clr);
        // TODO Cater for more than 1 related field
        boolean dependent = fmd.isDependent();
        boolean hasFK = false;
        if (!dependent)
        {
            // Not dependent, so check if the datastore has a FK and will take care of it for us
            if (fmd.getForeignKeyMetaData() != null)
            {
                hasFK = true;
            }
            if (relatedMmds != null && relatedMmds[0].getForeignKeyMetaData() != null)
            {
                hasFK = true;
            }
            if (sm.getObjectManager().getOMFContext().getPersistenceConfiguration().getStringProperty("org.jpox.deletionPolicy").equals("JDO2"))
            {
                // JDO2 doesnt currently (2.0 spec) take note of foreign-key
                hasFK = false;
            }
        }

        // Basic rules for the following :-
        // 1. If it is dependent then we delete it (maybe after nulling).
        // 2. If it is not dependent and they have defined no FK then null it, else delete it
        // 3. If it is not dependent and they have a FK, let the datastore handle the delete
        // There may be some corner cases that this code doesnt yet cater for
        int relationType = fmd.getRelationType(clr);
        if (pc != null)
        {
            if (relationType == Relation.ONE_TO_ONE_UNI ||
                (relationType == Relation.ONE_TO_ONE_BI && fmd.getMappedBy() == null))
            {
                // 1-1 with FK at this side (owner of the relation)
                if (dependent)
                {
                    boolean relatedObjectDeleted = sm.getObjectManager().getApiAdapter().isDeleted(pc);
                    if (isNullable() && !relatedObjectDeleted)
                    {
                        // Other object not yet deleted - just null out the FK
                        // TODO Not doing this would cause errors in 1-1 uni relations (e.g AttachDetachTest)
                        // TODO Log this since it affects the resultant objects
                        sm.replaceField(fieldNumber, null, true);
                        sm.getStoreManager().getPersistenceHandler().updateObject(sm, new int[]{fieldNumber});
                    }
                    if (!relatedObjectDeleted)
                    {
                        // Mark the other object for deletion since not yet tagged
                        sm.getObjectManager().deleteObjectInternal(pc);
                    }
                }
                else
                {
                    // We're deleting the FK at this side so shouldnt be an issue
                    AbstractMemberMetaData relatedMmd = fmd.getRelatedMemberMetaDataForObject(clr, sm.getObject(), pc);
                    if (relatedMmd != null)
                    {
                        StateManager otherSM = sm.getObjectManager().findStateManager(pc);
                        if (otherSM != null)
                        {
                            // Managed Relations : 1-1 bidir, so null out the object at the other
                            if (JPOXLogger.PERSISTENCE.isDebugEnabled())
                            {
                                JPOXLogger.PERSISTENCE.debug(LOCALISER.msg("041019",
                                    StringUtils.toJVMIDString(pc), relatedMmd.getFullFieldName(),
                                    StringUtils.toJVMIDString(sm.getObject())));
                            }
                            otherSM.replaceField(relatedMmd.getAbsoluteFieldNumber(), null, true);
                        }
                    }
                }
            }
            else if (relationType == Relation.ONE_TO_ONE_BI && fmd.getMappedBy() != null)
            {
                // 1-1 with FK at other side
                DatastoreClass relatedTable = storeMgr.getDatastoreClass(relatedMmds[0].getClassName(), clr);
                JavaTypeMapping relatedMapping = relatedTable.getFieldMapping(relatedMmds[0]);
                boolean isNullable = relatedMapping.isNullable();
                StateManager otherSM = sm.getObjectManager().findStateManager(pc);
                if (dependent)
                {
View Full Code Here

Examples of org.jpox.store.mapped.MappedStoreManager

            if (this.conn == null)
            {
                Connection cnx = null;
                try
                {
                    MappedStoreManager storeMgr = (MappedStoreManager)omfContext.getStoreManager();
                    if (storeMgr != null && storeMgr.getDatastoreAdapter() != null)
                    {
                        // Create Connection following DatastoreAdapter capabilities
                        RDBMSAdapter rdba = (RDBMSAdapter)storeMgr.getDatastoreAdapter();
                        int reqdIsolationLevel = isolation;
                        if (rdba.getRequiredTransactionIsolationLevel() >= 0)
                        {
                            // Override with the adapters required isolation level
                            reqdIsolationLevel = rdba.getRequiredTransactionIsolationLevel();
View Full Code Here

Examples of org.jpox.store.mapped.MappedStoreManager

            schemaName = properties.getProperty("schema-name");
        }
        String tableName = (properties.getProperty("sequence-table-name") == null ?
                DEFAULT_TABLE_NAME : properties.getProperty("sequence-table-name"));

        MappedStoreManager storeMgr = (MappedStoreManager)this.storeMgr;
        SQLIdentifier identifier = (SQLIdentifier)storeMgr.getIdentifierFactory().newDatastoreContainerIdentifier(tableName);
        if (((RDBMSAdapter)storeMgr.getDatastoreAdapter()).supportsCatalogsInTableDefinitions() && catalogName != null)
        {
            identifier.setCatalogName(catalogName);
        }
        if (((RDBMSAdapter)storeMgr.getDatastoreAdapter()).supportsSchemasInTableDefinitions() && schemaName != null)
        {
            identifier.setSchemaName(schemaName);
        }

        DatastoreClass table = storeMgr.getDatastoreClass(identifier);
        if (table != null)
        {
            sequenceTable = (SequenceTable)table;
        }
        else
        {
            String sequenceNameColumnName = "SEQUENCE_NAME";
            String nextValColumnName = "NEXT_VAL";
            if (properties.getProperty("sequence-name-column-name") != null)
            {
                sequenceNameColumnName = properties.getProperty("sequence-name-column-name");
            }
            if (properties.getProperty("sequence-nextval-column-name") != null)
            {
                nextValColumnName = properties.getProperty("sequence-nextval-column-name");
            }
            sequenceTable = new SequenceTable(identifier, (RDBMSManager)storeMgr, sequenceNameColumnName, nextValColumnName);
            sequenceTable.initialize(storeMgr.getOMFContext().getClassLoaderResolver(null));
            storeMgr.addDatastoreContainer(sequenceTable);
        }
    }
View Full Code Here

Examples of org.jpox.store.mapped.MappedStoreManager

        // Compile the candidates
        compileCandidates();

        // Create a QueryStatement so that we can generate the query expressions for the parts of the query
        // The statement is thrown away after the precompile currently
        MappedStoreManager storeMgr = (MappedStoreManager)query.getObjectManager().getStoreManager();
        DatastoreIdentifier candidateAliasId = storeMgr.getIdentifierFactory().newIdentifier(
                IdentifierFactory.TABLE, candidateAlias);
        qs = candidates.newQueryStatement(candidateClass, candidateAliasId);
        if (parentExpr != null)
        {
            // Register subquery with its parent query expression
View Full Code Here

Examples of org.jpox.store.mapped.MappedStoreManager

            ((ResultExpressionsQueryable)candidates).setHasAggregatedExpressionsOnly(
                ((AbstractJavaQuery)query).resultHasOnlyAggregates(query.getResult()));
        }

        // Create the QueryStatement so we can generate the executable query
        MappedStoreManager storeMgr = (MappedStoreManager)query.getObjectManager().getStoreManager();
        DatastoreIdentifier candidateAliasId = storeMgr.getIdentifierFactory().newIdentifier(
                IdentifierFactory.TABLE, candidateAlias);
        qs = candidates.newQueryStatement(candidateClass, candidateAliasId);
        if (parentExpr != null)
        {
            // Register subquery with its parent query expression
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.