Examples of AbstractClassMetaData


Examples of org.jpox.metadata.AbstractClassMetaData

        {
            throw new JPOXUserException(LOCALISER.msg("010028"));
        }
        assertClassPersistable(pcClass);

        AbstractClassMetaData cmd = getMetaDataManager().getMetaDataForClass(pcClass, clr);
        if (cmd == null)
        {
            throw new NoPersistenceInformationException(pcClass.getName());
        }

        // If the class is not yet managed, manage it
        if (!getStoreManager().managesClass(cmd.getFullClassName()))
        {
            getStoreManager().addClass(cmd.getFullClassName(), clr);
        }

        Object id = null;
        if (cmd.usesSingleFieldIdentityClass())
        {
            // Single Field Identity
            Class idType = clr.classForName(cmd.getObjectidClass());
            id = getApiAdapter().getNewSingleFieldIdentity(idType, pcClass, key);
        }
        else if (key instanceof java.lang.String)
        {
            // String-based PK (datastore identity or application identity)
            if (cmd.getIdentityType() == IdentityType.APPLICATION)
            {
                if (Modifier.isAbstract(pcClass.getModifiers()) && cmd.getObjectidClass() != null)
                {
                    try
                    {
                        Constructor c = clr.classForName(cmd.getObjectidClass()).getDeclaredConstructor(new Class[] {java.lang.String.class});
                        id = c.newInstance(new Object[] {(String)key});
                    }
                    catch(Exception e)
                    {
                        String msg = LOCALISER.msg("010030", cmd.getObjectidClass(), cmd.getFullClassName());
                        JPOXLogger.PERSISTENCE.error(msg);
                        JPOXLogger.PERSISTENCE.error(e);

                        throw new JPOXUserException(msg);
                    }
View Full Code Here

Examples of org.jpox.metadata.AbstractClassMetaData

     * @param pc The persistable object. Used for application-identity
     * @return A new object ID.
     */
    public Object newObjectId(String className, Object pc)
    {
        AbstractClassMetaData cmd = getMetaDataManager().getMetaDataForClass(className, getClassLoaderResolver());
        if (cmd.getIdentityType() == IdentityType.DATASTORE)
        {
            // Populate any strategy value for the "datastore-identity" element
            Object nextIdentifier = getStoreManager().getStrategyValue(this, cmd, -1);
            return OIDFactory.getInstance(this, cmd.getFullClassName(), nextIdentifier);
        }
        else if (cmd.getIdentityType() == IdentityType.APPLICATION)
        {
            return getApiAdapter().getNewApplicationIdentityObjectId(pc, cmd); // All values will have been populated before arriving here
        }
        else
        {
View Full Code Here

Examples of org.jpox.metadata.AbstractClassMetaData

        // Put into Level 2 Cache
        if (level2 && this.omf.getBooleanProperty("org.jpox.cache.level2"))
        {
            boolean storeInL2Cache = true;
            AbstractClassMetaData acmd = getMetaDataManager().getMetaDataForClass(sm.getObject().getClass(), clr);
            if (acmd != null && acmd.getIdentityType() == IdentityType.APPLICATION)
            {
                // If using compound identity dont put it in the L2 Cache (the id uses a PC which we can't link to)
                int[] pkFieldNumbers = acmd.getPKMemberPositions();
                for (int i=0;i<pkFieldNumbers.length;i++)
                {
                    AbstractMemberMetaData fmd = acmd.getMetaDataForManagedMemberAtAbsolutePosition(pkFieldNumbers[i]);
                    if (getApiAdapter().isPersistable(fmd.getType()))
                    {
                        storeInL2Cache = false;
                    }
                }
View Full Code Here

Examples of org.jpox.metadata.AbstractClassMetaData

                            classesNeedingAdding.add(data.getName());
                            if (data.getMetaData() == null)
                            {
                                // StoreData doesnt have its metadata set yet so load it
                                // This ensures that the MetaDataManager always knows about these classes
                                AbstractClassMetaData acmd =
                                    getMetaDataManager().getMetaDataForClass(classFound, clr);
                                if (acmd != null)
                                {
                                    data.setMetaData(acmd);
                                }
View Full Code Here

Examples of org.jpox.metadata.AbstractClassMetaData

        if (id instanceof OID)
        {
            // Check that the implied class is managed
            className = ((OID)id).getPcClass();
            AbstractClassMetaData cmd = getMetaDataManager().getMetaDataForClass(className, clr);
            if (cmd.getIdentityType() != IdentityType.DATASTORE)
            {
                throw new JPOXUserException(LOCALISER.msg("038001", id, cmd.getFullClassName()));
            }

        }
        else if (getApiAdapter().isSingleFieldIdentity(id))
        {
            className = getApiAdapter().getTargetClassNameForSingleFieldIdentity(id);
            AbstractClassMetaData cmd = getMetaDataManager().getMetaDataForClass(className, clr);
            if (cmd.getIdentityType() != IdentityType.APPLICATION || !cmd.getObjectidClass().equals(id.getClass().getName()))
            {
                throw new JPOXUserException(LOCALISER.msg("038001", id, cmd.getFullClassName()));
            }
        }
        else
        {
            throw new JPOXException("StoreManager.manageClassForIdentity called for id=" + id +
View Full Code Here

Examples of org.jpox.metadata.AbstractClassMetaData

                bExpr = expr.expressionList.getExpression(0).eq(oidExpr);
            }
            else
            {
                ApiAdapter api = qs.getStoreManager().getApiAdapter();
                AbstractClassMetaData cmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(value.getClass(), clr);
                if (cmd == null)
                {
                    // if there is no metadata, we either have an SingleFieldIdentity, application identity, or any object
                    if (storeMgr.getApiAdapter().isSingleFieldIdentityClass(value.getClass().getName()))
                    {
                        // Object is SingleFieldIdentity
                        JavaTypeMapping m = dba.getMapping(api.getTargetClassForSingleFieldIdentity(value), storeMgr, clr);
                        ScalarExpression oidExpr =  m.newLiteral(qs, api.getTargetKeyForSingleFieldIdentity(value));
                        bExpr = expr.expressionList.getExpression(0).eq(oidExpr);
                    }
                    else
                    {
                        String pcClassName = storeMgr.getClassNameForObjectID(value, clr, null);
                        if (pcClassName != null)
                        {
                            // Object is an application identity
                            cmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(pcClassName, clr);
                            bExpr = eqApplicationIdentity(value, null, expr, null, storeMgr, clr);
                        }
                        else
                        {
                            // Value not PersistenceCapable nor an identity, so return nothing "(1 = 0)"
                            bExpr = new BooleanLiteral(qs, mapping, false).eq(new BooleanLiteral(qs, mapping, true));
                        }
                    }
                }
                else
                {
                    // Value is a PersistenceCapable
                    if (cmd.getIdentityType() == IdentityType.APPLICATION)
                    {
                        // Application identity
                        if (api.getIdForObject(value) != null)
                        {
                            // Persistent PC object (FCO)
                            // Cater for composite PKs and parts of PK being PC mappings, and recursion
                            JavaTypeMapping[] pkMappingsApp = new JavaTypeMapping[expr.expressionList.size()];
                            Object[] pkFieldValues = new Object[expr.expressionList.size()];
                            int position = 0;
                            for (int i=0;i<cmd.getNoOfPrimaryKeyMembers();i++)
                            {
                                AbstractMemberMetaData mmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(cmd.getPKMemberPositions()[i]);
                                Object fieldValue = getFieldValue(mmd, value);
                                JavaTypeMapping mapping = dba.getMapping(fieldValue.getClass(), storeMgr, clr);
                                if (mapping instanceof PersistenceCapableMapping)
                                {
                                    position = populatePrimaryKeyMappingsValuesForPCMapping(pkMappingsApp,
View Full Code Here

Examples of org.jpox.metadata.AbstractClassMetaData

                position++;
            }
        }
        else
        {
            AbstractClassMetaData pcCmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(pcMapping.getType(), clr);
            int[] pcPkPositions = pcCmd.getPKMemberPositions();
            for (int k=0;k<subMappings.length;k++)
            {
                AbstractMemberMetaData pcMmd = pcCmd.getMetaDataForManagedMemberAtAbsolutePosition(pcPkPositions[k]);
                if (subMappings[k] instanceof PersistenceCapableMapping)
                {
                    Object val = getFieldValue(pcMmd, fieldValue);
                    position = populatePrimaryKeyMappingsValuesForPCMapping(pkMappings, pkFieldValues, position,
                        (PersistenceCapableMapping)subMappings[k], pcCmd, pcMmd, val, storeMgr, clr);
View Full Code Here

Examples of org.jpox.metadata.AbstractClassMetaData

    public ScalarExpression accessField(String subfieldName, boolean innerJoin)
    {
        Object fieldValue = null;
        try
        {
            AbstractClassMetaData acmd = qs.getStoreManager().getOMFContext().getMetaDataManager().getMetaDataForClass(this.mappingClass,
                qs.getClassLoaderResolver());
            if( acmd == null )
            {
                //no pc classes
                fieldValue = getFieldValue(value, subfieldName);
            }
            else
            {
                AbstractMemberMetaData fmd =acmd.getMetaDataForMember(subfieldName);
                if( fmd == null )
                {
                    throw new JPOXUserException("Cannot access field "+subfieldName+" on type "+this.mappingClass);
                }
                fieldValue = getFieldValue(fmd, value);
View Full Code Here

Examples of org.jpox.metadata.AbstractClassMetaData

                datastoreContainer, fmd, clr, fmd.isEmbedded() || fmd.getElementMetaData() != null);
        }
        else
        {
            // Either one end of a 1-1 relation, or the N end of a N-1
            AbstractClassMetaData refCmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForInterface(fmd.getType(), clr);
            JavaTypeMapping referenceMapping = null;
            if (refCmd != null && refCmd.getInheritanceMetaData().getStrategyValue() == InheritanceStrategy.SUBCLASS_TABLE)
            {
                // TODO Is this block actually reachable ? Would we specify "inheritance" under "interface" elements?
                // Find the actual tables storing the other end (can be multiple subclasses)
                AbstractClassMetaData[] cmds = storeMgr.getClassesManagingTableForClass(refCmd, clr);
                if (cmds != null && cmds.length > 0)
View Full Code Here

Examples of org.jpox.metadata.AbstractClassMetaData

            mc = getValueMappingClass(datastoreContainer, fmd, dba, clr);
        }
        else
        {
            // Assumed to be a normal field
            AbstractClassMetaData acmd = null;
            if (fmd.getType().isInterface())
            {
                acmd = datastoreContainer.getStoreManager().getOMFContext().getMetaDataManager().getMetaDataForInterface(fmd.getType(), clr);
            }
            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());
            }
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.