Search in sources :

Example 76 with NucleusException

use of org.datanucleus.exceptions.NucleusException in project datanucleus-rdbms by datanucleus.

the class SQLExpressionFactory method invokeOperation.

/**
 * Accessor for the result of an SQLOperation call on the supplied expression with the supplied args.
 * Throws a NucleusException is the method is not supported.
 * @param name Operation to be invoked
 * @param expr The first expression to perform the operation on
 * @param expr2 The second expression to perform the operation on
 * @return The result
 * @throws UnsupportedOperationException if the operation is not specified
 */
public SQLExpression invokeOperation(String name, SQLExpression expr, SQLExpression expr2) {
    // Check for instantiated plugin SQLOperation
    DatastoreAdapter dba = storeMgr.getDatastoreAdapter();
    SQLOperation operation = sqlOperationsByName.get(name);
    if (operation != null) {
        return operation.getExpression(expr, expr2);
    }
    // Check for built-in SQLOperation class definition
    Class sqlOpClass = dba.getSQLOperationClass(name);
    if (sqlOpClass != null) {
        try {
            // Instantiate it
            operation = (SQLOperation) sqlOpClass.getDeclaredConstructor().newInstance();
            sqlOperationsByName.put(name, operation);
            return operation.getExpression(expr, expr2);
        } catch (Exception e) {
            throw new NucleusException("Error creating SQLOperation of type " + sqlOpClass.getName() + " for operation " + name);
        }
    }
    // Check for plugin definition of this operation for this datastore
    // 1). Try datastore-dependent key
    String datastoreId = dba.getVendorID();
    String key = getSQLOperationKey(datastoreId, name);
    boolean datastoreDependent = true;
    if (!pluginSqlOperationKeysSupported.contains(key)) {
        // 2). No datastore-dependent method, so try a datastore-independent key
        key = getSQLOperationKey(null, name);
        datastoreDependent = false;
        if (!pluginSqlOperationKeysSupported.contains(key)) {
            throw new UnsupportedOperationException("Operation " + name + " on datastore=" + datastoreId + " not supported");
        }
    }
    PluginManager pluginMgr = storeMgr.getNucleusContext().getPluginManager();
    String[] attrNames = (datastoreDependent ? new String[] { "name", "datastore" } : new String[] { "name" });
    String[] attrValues = (datastoreDependent ? new String[] { name, datastoreId } : new String[] { name });
    try {
        operation = (SQLOperation) pluginMgr.createExecutableExtension("org.datanucleus.store.rdbms.sql_operation", attrNames, attrValues, "evaluator", null, null);
        synchronized (operation) {
            sqlOperationsByName.put(key, operation);
            return operation.getExpression(expr, expr2);
        }
    } catch (Exception e) {
        throw new NucleusUserException(Localiser.msg("060011", "operation=" + name), e);
    }
}
Also used : PluginManager(org.datanucleus.plugin.PluginManager) SQLOperation(org.datanucleus.store.rdbms.sql.operation.SQLOperation) NucleusUserException(org.datanucleus.exceptions.NucleusUserException) DatastoreAdapter(org.datanucleus.store.rdbms.adapter.DatastoreAdapter) NucleusException(org.datanucleus.exceptions.NucleusException) NucleusUserException(org.datanucleus.exceptions.NucleusUserException) NucleusException(org.datanucleus.exceptions.NucleusException) ClassNotResolvedException(org.datanucleus.exceptions.ClassNotResolvedException)

Example 77 with NucleusException

use of org.datanucleus.exceptions.NucleusException in project datanucleus-core by datanucleus.

the class PlatformManagementServer method unregisterMBean.

/**
 * Unregister a MBean from the MBeanServer
 * @param name the mbean name
 */
public void unregisterMBean(String name) {
    try {
        ObjectName objName = new ObjectName(name);
        mbeanServer.unregisterMBean(objName);
    } catch (Exception e) {
        throw new NucleusException(e.getMessage(), e);
    }
}
Also used : NucleusException(org.datanucleus.exceptions.NucleusException) NucleusException(org.datanucleus.exceptions.NucleusException) ObjectName(javax.management.ObjectName)

Example 78 with NucleusException

use of org.datanucleus.exceptions.NucleusException in project datanucleus-core by datanucleus.

the class ClassMetaData method populate.

/**
 * Method to provide the details of the class being represented by this MetaData.
 * This can be used to firstly provide defaults for attributes that aren't specified in the MetaData,
 * and secondly to report any errors with attributes that have been specified that are inconsistent with the
 * class being represented.
 * <P>
 * One possible use of this method would be to take a basic ClassMetaData for a class and call this, passing in the users class.
 * This would then add AbstractMemberMetaData for all fields in this class providing defaults for all of these.
 * @param clr ClassLoaderResolver to use in loading any classes
 * @param primary the primary ClassLoader to use (or null)
 * @param mgr MetaData manager
 */
public synchronized void populate(ClassLoaderResolver clr, ClassLoader primary, MetaDataManager mgr) {
    if (isInitialised() || isPopulated()) {
        NucleusLogger.METADATA.error(Localiser.msg("044068", name));
        throw new NucleusException(Localiser.msg("044068", fullName)).setFatal();
    }
    if (populating) {
        return;
    }
    this.mmgr = mgr;
    try {
        if (NucleusLogger.METADATA.isDebugEnabled()) {
            NucleusLogger.METADATA.debug(Localiser.msg("044075", fullName));
        }
        populating = true;
        Class cls = loadClass(clr, primary);
        isAbstract = Modifier.isAbstract(cls.getModifiers());
        // Load any Annotations definition for this class
        if (!isMetaDataComplete()) {
            mmgr.addAnnotationsDataToClass(cls, this, clr);
        }
        // Load any ORM definition for this class
        mmgr.addORMDataToClass(cls, clr);
        // If a class is an inner class and is non-static it is invalid
        if (ClassUtils.isInnerClass(fullName) && !Modifier.isStatic(cls.getModifiers()) && persistenceModifier == ClassPersistenceModifier.PERSISTENCE_CAPABLE) {
            throw new InvalidClassMetaDataException("044063", fullName);
        }
        if (entityName == null) {
            // No entity name given so just default to the name of the class (without package)
            this.entityName = name;
        }
        determineSuperClassName(clr, cls);
        inheritIdentity();
        determineIdentity();
        validateUserInputForIdentity();
        addMetaDataForMembersNotInMetaData(cls);
        // Set inheritance
        validateUserInputForInheritanceMetaData(isAbstract());
        determineInheritanceMetaData();
        applyDefaultDiscriminatorValueWhenNotSpecified();
        // Process all members marked as UNKNOWN (i.e override from JPA) and eliminate clashes with any generic overrides from addMetaDataForMembersNotInMetaData(...)
        Iterator<AbstractMemberMetaData> memberIter = members.iterator();
        Set<AbstractMemberMetaData> membersToDelete = null;
        while (memberIter.hasNext()) {
            AbstractMemberMetaData mmd = memberIter.next();
            if (mmd.className != null && mmd.className.equals("#UNKNOWN")) {
                // Field is for a superclass but we didn't know which at creation so resolve it
                if (pcSuperclassMetaData == null) {
                    // No superclass so it doesn't make sense so assume to be for this class
                    mmd.className = null;
                } else {
                    AbstractMemberMetaData superFmd = pcSuperclassMetaData.getMetaDataForMember(mmd.getName());
                    if (superFmd != null) {
                        // Field is for a superclass so set its "className"
                        mmd.className = (superFmd.className != null) ? superFmd.className : superFmd.getClassName();
                        // Copy across other attributes of the original definition
                        mmd.primaryKey = superFmd.primaryKey;
                        mmd.persistenceModifier = superFmd.persistenceModifier;
                        mmd.valueStrategy = superFmd.valueStrategy;
                        mmd.valueGeneratorName = superFmd.valueGeneratorName;
                        mmd.sequence = superFmd.sequence;
                        mmd.cacheable = superFmd.cacheable;
                        mmd.storeInLob = superFmd.storeInLob;
                        // TODO Copy across more attributes
                        Iterator<AbstractMemberMetaData> existingMemberIter = members.iterator();
                        while (existingMemberIter.hasNext()) {
                            AbstractMemberMetaData existingMmd = existingMemberIter.next();
                            if (existingMmd.getName().equals(mmd.getName()) && existingMmd != mmd) {
                                mmd.type = existingMmd.getType();
                                if (membersToDelete == null) {
                                    membersToDelete = new HashSet<>();
                                }
                                membersToDelete.add(existingMmd);
                                break;
                            }
                        }
                    }
                }
            }
        }
        if (membersToDelete != null) {
            members.removeAll(membersToDelete);
        }
        if (objectidClass == null) {
            // No user-defined objectid-class but potentially have SingleFieldIdentity so make sure PK fields are set
            // PK fields
            populateMemberMetaData(clr, cls, true, primary);
            determineObjectIdClass();
            // Non-PK fields
            populateMemberMetaData(clr, cls, false, primary);
        } else {
            populateMemberMetaData(clr, cls, true, primary);
            populateMemberMetaData(clr, cls, false, primary);
            determineObjectIdClass();
        }
        validateUnmappedColumns();
        // populate the implements
        if (implementations != null) {
            for (ImplementsMetaData implmd : implementations) {
                implmd.populate(clr, primary);
            }
        }
        if (persistentInterfaceImplNeedingTableFromSuperclass) {
            // Need to go up to next superinterface and make sure its metadata is populated
            // until we find the next interface with metadata with inheritance strategy of "new-table".
            AbstractClassMetaData acmd = getMetaDataForSuperinterfaceManagingTable(cls, clr);
            if (acmd != null) {
                table = acmd.table;
                schema = acmd.schema;
                catalog = acmd.catalog;
            }
            persistentInterfaceImplNeedingTableFromSuperclass = false;
        } else if (persistentInterfaceImplNeedingTableFromSubclass) {
            // TODO Cater for finding the subclass-table that manages our table
            persistentInterfaceImplNeedingTableFromSubclass = false;
        }
        setPopulated();
    } catch (RuntimeException e) {
        NucleusLogger.METADATA.debug(e);
        throw e;
    } finally {
        populating = false;
    }
}
Also used : NucleusException(org.datanucleus.exceptions.NucleusException)

Example 79 with NucleusException

use of org.datanucleus.exceptions.NucleusException in project datanucleus-core by datanucleus.

the class MetaDataMerger method mergeClassAnnotationsData.

/**
 * Method to take a class XML metadata definition and merge in any Annotations metadata definition.
 * If something is specified in the XML and also in the annotations then the XML takes precedence.
 * This is tied pretty intrinsically to the AbstractClassMetaData class and so could have been included there.
 * @param primaryCmd The XML metadata definition (to be updated)
 * @param annotCmd The annotations metadata definition (to be merged into the XML definition)
 * @param mmgr MetaData manager
 * @throws NucleusException if an error occurs while merging the annotations info
 */
public static void mergeClassAnnotationsData(AbstractClassMetaData primaryCmd, AbstractClassMetaData annotCmd, MetaDataManager mmgr) {
    if (annotCmd == null || primaryCmd == null) {
        return;
    }
    if (primaryCmd.isInitialised() || primaryCmd.isPopulated()) {
        throw new NucleusException(Localiser.msg("044068", primaryCmd.name)).setFatal();
    }
    if (NucleusLogger.METADATA.isDebugEnabled()) {
        NucleusLogger.METADATA.debug(Localiser.msg("044095", primaryCmd.getFullClassName()));
    }
    // Merge any annotated information that is hanging off the package
    PackageMetaData annotPmd = annotCmd.getPackageMetaData();
    if (annotPmd.getSequences() != null) {
        // Register the sequences since the register process for the primaryCmd has passed
        mmgr.registerSequencesForFile(annotCmd.getPackageMetaData().getFileMetaData());
        SequenceMetaData[] seqmds = annotPmd.getSequences();
        for (int i = 0; i < seqmds.length; i++) {
            primaryCmd.getPackageMetaData().addSequence(seqmds[i]);
        }
    }
    if (annotPmd.getTableGenerators() != null) {
        // Register the table generators since the register process for the primaryCmd has passed
        mmgr.registerTableGeneratorsForFile(annotCmd.getPackageMetaData().getFileMetaData());
        TableGeneratorMetaData[] tablegenmds = annotPmd.getTableGenerators();
        for (int i = 0; i < tablegenmds.length; i++) {
            primaryCmd.getPackageMetaData().addTableGenerator(tablegenmds[i]);
        }
    }
    // A). Simple attributes
    if (primaryCmd.entityName == null && annotCmd.entityName != null) {
        primaryCmd.entityName = annotCmd.entityName;
    }
    if (annotCmd.detachable) {
        primaryCmd.detachable = true;
    }
    if (!annotCmd.requiresExtent) {
        primaryCmd.requiresExtent = false;
    }
    if (annotCmd.embeddedOnly) {
        primaryCmd.embeddedOnly = true;
    }
    if (primaryCmd.identityType == null && annotCmd.identityType != null) {
        primaryCmd.identityType = annotCmd.identityType;
    }
    if (primaryCmd.objectidClass == null && annotCmd.objectidClass != null) {
        primaryCmd.objectidClass = annotCmd.objectidClass;
    }
    if (primaryCmd.catalog == null && annotCmd.catalog != null) {
        primaryCmd.catalog = annotCmd.catalog;
    }
    if (primaryCmd.schema == null && annotCmd.schema != null) {
        primaryCmd.schema = annotCmd.schema;
    }
    if (primaryCmd.table == null && annotCmd.table != null) {
        primaryCmd.table = annotCmd.table;
    }
    // B). Object data - assume that we copy it all if not set at all
    if (primaryCmd.versionMetaData == null && annotCmd.versionMetaData != null) {
        primaryCmd.setVersionMetaData(annotCmd.versionMetaData);
    }
    if (primaryCmd.identityMetaData == null && annotCmd.identityMetaData != null) {
        primaryCmd.setIdentityMetaData(annotCmd.identityMetaData);
    }
    if (primaryCmd.inheritanceMetaData == null && annotCmd.inheritanceMetaData != null) {
        primaryCmd.setInheritanceMetaData(annotCmd.inheritanceMetaData);
    }
    if (primaryCmd.primaryKeyMetaData == null && annotCmd.primaryKeyMetaData != null) {
        primaryCmd.setPrimaryKeyMetaData(annotCmd.primaryKeyMetaData);
    }
    if (primaryCmd.listeners == null && annotCmd.listeners != null) {
        // No XML listeners so just use those of the annotations
        Iterator iter = annotCmd.listeners.iterator();
        while (iter.hasNext()) {
            primaryCmd.addListener((EventListenerMetaData) iter.next());
        }
    } else if (primaryCmd.listeners != null && annotCmd.listeners != null) {
        // We have listeners in XML and also in Annotations. Listeners can be for the actual class, or for any EntityListener, so use overriding in those two groups
        if (primaryCmd.getListenerForClass(primaryCmd.getFullClassName()) == null) {
            // Primary has just Listeners and no callbacks
            if (annotCmd.getListenerForClass(primaryCmd.getFullClassName()) != null) {
                // Add on callbacks from annotations
                primaryCmd.addListener(annotCmd.getListenerForClass(primaryCmd.getFullClassName()));
            }
        } else if (primaryCmd.getListenerForClass(primaryCmd.getFullClassName()) != null && primaryCmd.getListeners().size() == 1) {
            // XML has just callbacks and no listeners so take any listeners from annotations
            List annotListeners = annotCmd.getListeners();
            Iterator annotIter = annotListeners.iterator();
            while (annotIter.hasNext()) {
                EventListenerMetaData elmd = (EventListenerMetaData) annotIter.next();
                if (!elmd.getClassName().equals(primaryCmd.getFullClassName())) {
                    // Add on listeners from annotations
                    primaryCmd.addListener(elmd);
                }
            }
        }
    }
    if (annotCmd.excludeDefaultListeners != null && primaryCmd.excludeDefaultListeners == null) {
        primaryCmd.excludeDefaultListeners = annotCmd.excludeDefaultListeners;
    }
    if (annotCmd.excludeSuperClassListeners != null && primaryCmd.excludeSuperClassListeners == null) {
        primaryCmd.excludeSuperClassListeners = annotCmd.excludeSuperClassListeners;
    }
    if (primaryCmd.queries == null && annotCmd.queries != null) {
        Iterator iter = annotCmd.queries.iterator();
        while (iter.hasNext()) {
            primaryCmd.addQuery((QueryMetaData) iter.next());
        }
    }
    if (primaryCmd.joins == null && annotCmd.joins != null) {
        Iterator iter = annotCmd.joins.iterator();
        while (iter.hasNext()) {
            primaryCmd.addJoin((JoinMetaData) iter.next());
        }
    }
    if (primaryCmd.indexes == null && annotCmd.indexes != null) {
        Iterator iter = annotCmd.indexes.iterator();
        while (iter.hasNext()) {
            primaryCmd.addIndex((IndexMetaData) iter.next());
        }
    }
    if (primaryCmd.foreignKeys == null && annotCmd.foreignKeys != null) {
        Iterator iter = annotCmd.foreignKeys.iterator();
        while (iter.hasNext()) {
            primaryCmd.addForeignKey((ForeignKeyMetaData) iter.next());
        }
    }
    if (primaryCmd.uniqueConstraints == null && annotCmd.uniqueConstraints != null) {
        Iterator iter = annotCmd.uniqueConstraints.iterator();
        while (iter.hasNext()) {
            primaryCmd.addUniqueConstraint((UniqueMetaData) iter.next());
        }
    }
    if (primaryCmd.fetchGroups == null && annotCmd.fetchGroups != null) {
        Iterator iter = annotCmd.fetchGroups.iterator();
        while (iter.hasNext()) {
            primaryCmd.addFetchGroup((FetchGroupMetaData) iter.next());
        }
    }
    // C). Add on any fields that weren't defined previously
    for (int i = 0; i < annotCmd.getNoOfMembers(); i++) {
        AbstractMemberMetaData annotFmd = annotCmd.getMetaDataForMemberAtRelativePosition(i);
        AbstractMemberMetaData primaryFmd = primaryCmd.getMetaDataForMember(annotFmd.getName());
        if (primaryFmd == null) {
            // Field not specified in XML but is in Annotations
            AbstractMemberMetaData fmd = null;
            if (annotFmd.className != null) {
                // Overridden field for superclass that we have no XML field for
                // Copy the fmd for the actual class (if any).
                // TODO Replace this with a copy of the metadata version of the field if available
                AbstractMemberMetaData baseFmd = mmgr.readMetaDataForMember(annotFmd.className, annotFmd.name);
                if (baseFmd == null) {
                    baseFmd = mmgr.readMetaDataForMember(annotCmd.getPackageName() + "." + annotFmd.className, annotFmd.name);
                }
                if (baseFmd != null) {
                    // Make a copy of the base field definition and merge the Annotations
                    if (baseFmd instanceof FieldMetaData) {
                        // Copy the JDO definition of the superclass since no JDO definition in this class
                        fmd = new FieldMetaData(primaryCmd, baseFmd);
                    } else {
                        // Copy the JDO definition of the superclass since no JDO definition in this class
                        fmd = new PropertyMetaData(primaryCmd, (PropertyMetaData) baseFmd);
                    }
                    fmd.className = annotFmd.className;
                    MetaDataMerger.mergeMemberAnnotationsData(fmd, annotFmd);
                } else {
                    // No base field definition so just copy the Annotations
                    if (annotFmd instanceof FieldMetaData) {
                        // Create default field since no available definition
                        fmd = new FieldMetaData(primaryCmd, annotFmd);
                    } else {
                        // Create default property since no available definition
                        fmd = new PropertyMetaData(primaryCmd, (PropertyMetaData) annotFmd);
                    }
                    fmd.className = annotFmd.className;
                }
            } else {
                // Create a copy of the Annotations metadata and add
                if (annotFmd instanceof FieldMetaData) {
                    // Annotation definition of the field
                    // creates a new fmd with this as parent and add to fields
                    fmd = new FieldMetaData(primaryCmd, annotFmd);
                } else {
                    // Annotation definition of the property
                    // creates a new fmd with this as parent and add to fields
                    fmd = new PropertyMetaData(primaryCmd, (PropertyMetaData) annotFmd);
                }
            }
            primaryCmd.addMember(fmd);
        } else {
            // Field specified in JDO MetaData so merge in Annotations
            MetaDataMerger.mergeMemberAnnotationsData(primaryFmd, annotFmd);
        }
    }
    // Add any extensions supplied in the annotations
    Map<String, String> ormExtensions = annotCmd.getExtensions();
    if (ormExtensions != null) {
        primaryCmd.addExtensions(ormExtensions);
    }
}
Also used : Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) NucleusException(org.datanucleus.exceptions.NucleusException)

Example 80 with NucleusException

use of org.datanucleus.exceptions.NucleusException in project datanucleus-core by datanucleus.

the class MetaDataMerger method mergeMemberORMData.

/**
 * Method to take a field JDO MetaData definition and merge in the ORM MetaData definition.
 * This is tied pretty intrinsically to the AbstractMemberMetaData class and so could have been included there.
 * @param primaryFmd The JDO Field definition (to be updated)
 * @param ormFmd The ORM Field definition (to be merged into the JDO Class definition)
 * @throws NucleusException if an error occurs while merging the ORM info
 */
static void mergeMemberORMData(AbstractMemberMetaData primaryFmd, AbstractMemberMetaData ormFmd) {
    if (ormFmd == null || primaryFmd == null) {
        return;
    }
    if (primaryFmd.isInitialised() || primaryFmd.isPopulated()) {
        throw new NucleusException(Localiser.msg("044107", primaryFmd.getClassName(), primaryFmd.getName())).setFatal();
    }
    if (ormFmd.persistenceModifier != null && ormFmd.persistenceModifier != FieldPersistenceModifier.DEFAULT && primaryFmd.persistenceModifier != ormFmd.persistenceModifier) {
        // Take the persistence-modifier from ORM since it is changed
        primaryFmd.persistenceModifier = ormFmd.persistenceModifier;
    }
    if (ormFmd.className != null) {
        // If the ORM is an overriding field, make sure we have the (real) class name
        primaryFmd.className = ormFmd.className;
    }
    if (ormFmd.containerMetaData != null) {
        primaryFmd.containerMetaData = ormFmd.containerMetaData;
        primaryFmd.containerMetaData.parent = primaryFmd;
    }
    // Update our O/R mapping details
    if (ormFmd.defaultFetchGroup != null) {
        primaryFmd.defaultFetchGroup = ormFmd.defaultFetchGroup;
    }
    /*if (Boolean.FALSE.equals(primaryFmd.primaryKey) && Boolean.TRUE.equals(ormFmd.primaryKey))
        {
            primaryFmd.primaryKey = Boolean.valueOf(ormFmd.isPrimaryKey());
        }*/
    if (ormFmd.getTable() != null) {
        primaryFmd.table = ormFmd.getTable();
    }
    if (ormFmd.getCatalog() != null) {
        primaryFmd.catalog = ormFmd.getCatalog();
    }
    if (ormFmd.getSchema() != null) {
        primaryFmd.schema = ormFmd.getSchema();
    }
    if (ormFmd.column != null) {
        primaryFmd.column = ormFmd.column;
    }
    if (ormFmd.dependent != null) {
        primaryFmd.dependent = ormFmd.dependent;
    }
    if (ormFmd.getMappedBy() != null) {
        primaryFmd.mappedBy = ormFmd.getMappedBy();
    }
    if (ormFmd.getValueStrategy() != null) {
        primaryFmd.valueStrategy = ormFmd.getValueStrategy();
    }
    if (ormFmd.getSequence() != null) {
        primaryFmd.sequence = ormFmd.getSequence();
    }
    if (ormFmd.indexed != null) {
        primaryFmd.indexed = ormFmd.indexed;
    }
    if (ormFmd.nullValue != NullValue.NONE) {
        primaryFmd.nullValue = ormFmd.nullValue;
    }
    if (ormFmd.getJoinMetaData() != null) {
        primaryFmd.setJoinMetaData(ormFmd.joinMetaData);
    }
    if (ormFmd.getEmbeddedMetaData() != null) {
        primaryFmd.setEmbeddedMetaData(ormFmd.embeddedMetaData);
    }
    if (ormFmd.getElementMetaData() != null) {
        primaryFmd.setElementMetaData(ormFmd.elementMetaData);
    }
    if (ormFmd.getKeyMetaData() != null) {
        primaryFmd.setKeyMetaData(ormFmd.keyMetaData);
    }
    if (ormFmd.getValueMetaData() != null) {
        primaryFmd.setValueMetaData(ormFmd.valueMetaData);
    }
    if (ormFmd.getOrderMetaData() != null) {
        primaryFmd.setOrderMetaData(ormFmd.orderMetaData);
    }
    if (ormFmd.getForeignKeyMetaData() != null) {
        primaryFmd.foreignKeyMetaData = ormFmd.getForeignKeyMetaData();
        if (primaryFmd.foreignKeyMetaData != null) {
            primaryFmd.foreignKeyMetaData.parent = primaryFmd;
        }
    }
    if (ormFmd.getIndexMetaData() != null) {
        primaryFmd.indexMetaData = ormFmd.getIndexMetaData();
        if (primaryFmd.indexMetaData != null) {
            primaryFmd.indexMetaData.parent = primaryFmd;
        }
    }
    if (ormFmd.getUniqueMetaData() != null) {
        primaryFmd.uniqueMetaData = ormFmd.getUniqueMetaData();
        if (primaryFmd.uniqueMetaData != null) {
            primaryFmd.uniqueMetaData.parent = primaryFmd;
        }
    }
    ColumnMetaData[] ormColumns = ormFmd.getColumnMetaData();
    if (ormColumns != null) {
        primaryFmd.columns.clear();
        for (int i = 0; i < ormColumns.length; i++) {
            primaryFmd.columns.add(ormColumns[i]);
        }
    }
    // Add any extensions supplied in the ORM file
    Map<String, String> ormExtensions = ormFmd.getExtensions();
    if (ormExtensions != null) {
        primaryFmd.addExtensions(ormExtensions);
    }
}
Also used : NucleusException(org.datanucleus.exceptions.NucleusException)

Aggregations

NucleusException (org.datanucleus.exceptions.NucleusException)326 NucleusUserException (org.datanucleus.exceptions.NucleusUserException)71 SQLExpression (org.datanucleus.store.rdbms.sql.expression.SQLExpression)67 JavaTypeMapping (org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping)62 ParameterExpression (org.datanucleus.query.expression.ParameterExpression)53 PrimaryExpression (org.datanucleus.query.expression.PrimaryExpression)52 ArrayList (java.util.ArrayList)48 Literal (org.datanucleus.query.expression.Literal)47 AbstractMemberMetaData (org.datanucleus.metadata.AbstractMemberMetaData)44 SQLExpressionFactory (org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory)43 InvokeExpression (org.datanucleus.query.expression.InvokeExpression)40 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)37 ClassLoaderResolver (org.datanucleus.ClassLoaderResolver)36 StringExpression (org.datanucleus.store.rdbms.sql.expression.StringExpression)35 DatastoreClass (org.datanucleus.store.rdbms.table.DatastoreClass)35 Expression (org.datanucleus.query.expression.Expression)32 HashMap (java.util.HashMap)31 SelectStatement (org.datanucleus.store.rdbms.sql.SelectStatement)31 VariableExpression (org.datanucleus.query.expression.VariableExpression)26 RDBMSStoreManager (org.datanucleus.store.rdbms.RDBMSStoreManager)26