Package org.datanucleus.metadata

Examples of org.datanucleus.metadata.IdentityStrategy


    public Object getStrategyValue(ObjectManager om, AbstractClassMetaData cmd, int absoluteFieldNumber)
    {
        // Extract the control information for this field that needs its value
        AbstractMemberMetaData mmd = null;
        String fieldName = null;
        IdentityStrategy strategy = null;
        String sequence = null;
        String valueGeneratorName = null;
        TableGeneratorMetaData tableGeneratorMetaData = null;
        SequenceMetaData sequenceMetaData = null;
        if (absoluteFieldNumber >= 0)
        {
            // real field
            mmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(absoluteFieldNumber);
            fieldName = mmd.getFullFieldName();
            strategy = mmd.getValueStrategy();
            sequence = mmd.getSequence();
            valueGeneratorName = mmd.getValueGeneratorName();
        }
        else
        {
            // datastore-identity surrogate field
            fieldName = cmd.getFullClassName() + " (datastore id)";
            strategy = cmd.getIdentityMetaData().getValueStrategy();
            sequence = cmd.getIdentityMetaData().getSequence();
            valueGeneratorName = cmd.getIdentityMetaData().getValueGeneratorName();
        }

        // Extract any metadata-based generation information
        if (valueGeneratorName != null)
        {
            if (strategy == IdentityStrategy.INCREMENT)
            {
                tableGeneratorMetaData = getMetaDataManager().getMetaDataForTableGenerator(om.getClassLoaderResolver(),
                    valueGeneratorName);
                if (tableGeneratorMetaData == null)
                {
                    throw new NucleusUserException(LOCALISER.msg("038005", fieldName, valueGeneratorName));
                }
            }
            else if (strategy == IdentityStrategy.SEQUENCE)
            {
                sequenceMetaData = getMetaDataManager().getMetaDataForSequence(om.getClassLoaderResolver(),
                    valueGeneratorName);
                if (sequenceMetaData == null)
                {
                    throw new NucleusUserException(LOCALISER.msg("038006", fieldName, valueGeneratorName));
                }
            }
        }
        else if (strategy == IdentityStrategy.SEQUENCE && sequence != null)
        {
            // TODO Allow for package name of this class prefix for the sequence name
            sequenceMetaData = getMetaDataManager().getMetaDataForSequence(om.getClassLoaderResolver(), sequence);
            if (sequenceMetaData == null)
            {
                // JPOX 1.1 behaviour is just to use the sequence name in the datastore so log it and fallback to that
                NucleusLogger.VALUEGENERATION.warn("Field " + fieldName + " has been specified to use sequence " + sequence +
                    " but there is no <sequence> specified in the MetaData. " +
                    "Falling back to use a sequence in the datastore with this name directly.");
            }
        }

        String strategyName = strategy.toString();
        if (strategy.equals(IdentityStrategy.CUSTOM))
        {
            // Using a "custom" generator
            strategyName = strategy.getCustomName();
        }
        else if (strategy.equals(IdentityStrategy.NATIVE))
        {
            strategyName = getStrategyForNative(sequence);
        }

        // Value Generators are cached against a name. Some Value Generators are unique per datastore.
View Full Code Here


    /* (non-Javadoc)
     * @see javax.jdo.metadata.DatastoreIdentityMetadata#getCustomStrategy()
     */
    public String getCustomStrategy()
    {
        IdentityStrategy strategy = getInternal().getValueStrategy();
        if (strategy != IdentityStrategy.IDENTITY &&
            strategy != IdentityStrategy.INCREMENT &&
            strategy != IdentityStrategy.NATIVE &&
            strategy != IdentityStrategy.SEQUENCE &&
            strategy != IdentityStrategy.UUIDHEX &&
            strategy != IdentityStrategy.UUIDSTRING &&
            strategy != null)
        {
            return strategy.toString();
        }
        return null;
    }
View Full Code Here

    /* (non-Javadoc)
     * @see javax.jdo.metadata.DatastoreIdentityMetadata#getStrategy()
     */
    public IdGeneratorStrategy getStrategy()
    {
        IdentityStrategy strategy = getInternal().getValueStrategy();
        if (strategy == IdentityStrategy.IDENTITY)
        {
            return IdGeneratorStrategy.IDENTITY;
        }
        else if (strategy == IdentityStrategy.INCREMENT)
View Full Code Here

        return getInternal().getColumn();
    }

    public String getCustomStrategy()
    {
        IdentityStrategy strategy = getInternal().getValueStrategy();
        if (strategy != IdentityStrategy.IDENTITY &&
            strategy != IdentityStrategy.INCREMENT &&
            strategy != IdentityStrategy.NATIVE &&
            strategy != IdentityStrategy.SEQUENCE &&
            strategy != IdentityStrategy.UUIDHEX &&
            strategy != IdentityStrategy.UUIDSTRING &&
            strategy != null)
        {
            return strategy.toString();
        }
        return null;
    }
View Full Code Here

        return valmd;
    }

    public IdGeneratorStrategy getValueStrategy()
    {
        IdentityStrategy strategy = getInternal().getValueStrategy();
        if (strategy == IdentityStrategy.IDENTITY)
        {
            return IdGeneratorStrategy.IDENTITY;
        }
        else if (strategy == IdentityStrategy.INCREMENT)
View Full Code Here

                AbstractClassMetaData acmd = mdm.getMetaDataForClass(this.mmd.getType(), clr);
                if (acmd.getIdentityType() == IdentityType.APPLICATION)
                {
                    for (int i=0; i<acmd.getPKMemberPositions().length; i++)
                    {
                        IdentityStrategy strategy =
                            acmd.getMetaDataForManagedMemberAtAbsolutePosition(acmd.getPKMemberPositions()[i]).getValueStrategy();
                        if (strategy != null)
                        {
                            //if strategy is null, then it's user attributed value
                            hasDatastoreAttributedPrimaryKeyValues |= srm.isStrategyDatastoreAttributed(strategy, false);
View Full Code Here

TOP

Related Classes of org.datanucleus.metadata.IdentityStrategy

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.