Search in sources :

Example 16 with IndexMetaData

use of org.datanucleus.metadata.IndexMetaData in project datanucleus-api-jdo by datanucleus.

the class DiscriminatorMetadataImpl method newIndexMetadata.

/* (non-Javadoc)
     * @see javax.jdo.metadata.DiscriminatorMetadata#newIndexMetadata()
     */
public IndexMetadata newIndexMetadata() {
    IndexMetaData internalIdxmd = getInternal().newIndexMetaData();
    IndexMetadataImpl idxmd = new IndexMetadataImpl(internalIdxmd);
    idxmd.parent = this;
    return idxmd;
}
Also used : IndexMetaData(org.datanucleus.metadata.IndexMetaData)

Example 17 with IndexMetaData

use of org.datanucleus.metadata.IndexMetaData in project datanucleus-rdbms by datanucleus.

the class ElementContainerTable method getExpectedIndices.

/**
 * Accessor for the indices for this table.
 * This includes both the user-defined indices (via MetaData), and the ones required by
 * foreign keys (required by relationships).
 * @param clr The ClassLoaderResolver
 * @return The indices
 */
protected Set getExpectedIndices(ClassLoaderResolver clr) {
    assertIsInitialized();
    Set<Index> indices = new HashSet();
    // Index for FK back to owner
    if (mmd.getIndexMetaData() != null) {
        Index index = TableUtils.getIndexForField(this, mmd.getIndexMetaData(), ownerMapping);
        if (index != null) {
            indices.add(index);
        }
    } else if (mmd.getJoinMetaData() != null && mmd.getJoinMetaData().getIndexMetaData() != null) {
        Index index = TableUtils.getIndexForField(this, mmd.getJoinMetaData().getIndexMetaData(), ownerMapping);
        if (index != null) {
            indices.add(index);
        }
    } else {
        // Fallback to an index for the foreign-key to the owner
        Index index = TableUtils.getIndexForField(this, null, ownerMapping);
        if (index != null) {
            indices.add(index);
        }
    }
    // Index for FK to element (if required)
    if (elementMapping instanceof EmbeddedElementPCMapping) {
        // Add all indices required by fields of the embedded element
        EmbeddedElementPCMapping embMapping = (EmbeddedElementPCMapping) elementMapping;
        for (int i = 0; i < embMapping.getNumberOfJavaTypeMappings(); i++) {
            // Add indexes for fields of this embedded PC object
            JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i);
            IndexMetaData imd = embFieldMapping.getMemberMetaData().getIndexMetaData();
            if (imd != null) {
                Index index = TableUtils.getIndexForField(this, imd, embFieldMapping);
                if (index != null) {
                    indices.add(index);
                }
            }
        }
    } else {
        ElementMetaData elemmd = mmd.getElementMetaData();
        if (elemmd != null && elemmd.getIndexMetaData() != null) {
            Index index = TableUtils.getIndexForField(this, elemmd.getIndexMetaData(), elementMapping);
            if (index != null) {
                indices.add(index);
            }
        } else {
            // Fallback to an index for any foreign-key to the element
            if (elementMapping instanceof PersistableMapping) {
                Index index = TableUtils.getIndexForField(this, null, elementMapping);
                if (index != null) {
                    indices.add(index);
                }
            }
        }
    }
    if (orderMapping != null) {
        // Index for ordering?
        if (mmd.getOrderMetaData() != null && mmd.getOrderMetaData().getIndexMetaData() != null) {
            Index index = TableUtils.getIndexForField(this, mmd.getOrderMetaData().getIndexMetaData(), orderMapping);
            if (index != null) {
                indices.add(index);
            }
        }
    }
    return indices;
}
Also used : PersistableMapping(org.datanucleus.store.rdbms.mapping.java.PersistableMapping) JavaTypeMapping(org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping) ElementMetaData(org.datanucleus.metadata.ElementMetaData) Index(org.datanucleus.store.rdbms.key.Index) EmbeddedElementPCMapping(org.datanucleus.store.rdbms.mapping.java.EmbeddedElementPCMapping) HashSet(java.util.HashSet) IndexMetaData(org.datanucleus.metadata.IndexMetaData)

Example 18 with IndexMetaData

use of org.datanucleus.metadata.IndexMetaData in project datanucleus-api-jdo by datanucleus.

the class KeyMetadataImpl method getIndexMetadata.

/* (non-Javadoc)
     * @see javax.jdo.metadata.KeyMetadata#getIndexMetadata()
     */
public IndexMetadata getIndexMetadata() {
    IndexMetaData internalIdxmd = getInternal().getIndexMetaData();
    if (internalIdxmd == null) {
        return null;
    }
    IndexMetadataImpl idxmd = new IndexMetadataImpl(internalIdxmd);
    idxmd.parent = this;
    return idxmd;
}
Also used : IndexMetaData(org.datanucleus.metadata.IndexMetaData)

Example 19 with IndexMetaData

use of org.datanucleus.metadata.IndexMetaData in project datanucleus-api-jdo by datanucleus.

the class VersionMetadataImpl method getIndexMetadata.

/* (non-Javadoc)
     * @see javax.jdo.metadata.VersionMetadata#getIndexMetadata()
     */
public IndexMetadata getIndexMetadata() {
    IndexMetaData internalIdxmd = getInternal().getIndexMetaData();
    IndexMetadataImpl idxmd = new IndexMetadataImpl(internalIdxmd);
    idxmd.parent = this;
    return idxmd;
}
Also used : IndexMetaData(org.datanucleus.metadata.IndexMetaData)

Example 20 with IndexMetaData

use of org.datanucleus.metadata.IndexMetaData in project datanucleus-api-jdo by datanucleus.

the class OrderMetadataImpl method newIndexMetadata.

/* (non-Javadoc)
     * @see javax.jdo.metadata.OrderMetadata#newIndexMetadata()
     */
public IndexMetadata newIndexMetadata() {
    IndexMetaData internalIdxmd = getInternal().newIndexMetaData();
    IndexMetadataImpl idxmd = new IndexMetadataImpl(internalIdxmd);
    idxmd.parent = this;
    return idxmd;
}
Also used : IndexMetaData(org.datanucleus.metadata.IndexMetaData)

Aggregations

IndexMetaData (org.datanucleus.metadata.IndexMetaData)27 AbstractMemberMetaData (org.datanucleus.metadata.AbstractMemberMetaData)5 ForeignKeyMetaData (org.datanucleus.metadata.ForeignKeyMetaData)5 ColumnMetaData (org.datanucleus.metadata.ColumnMetaData)4 DiscriminatorMetaData (org.datanucleus.metadata.DiscriminatorMetaData)4 JoinMetaData (org.datanucleus.metadata.JoinMetaData)4 PrimaryKeyMetaData (org.datanucleus.metadata.PrimaryKeyMetaData)4 HashSet (java.util.HashSet)3 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)3 FetchGroupMetaData (org.datanucleus.metadata.FetchGroupMetaData)3 InvalidMetaDataException (org.datanucleus.metadata.InvalidMetaDataException)3 KeyMetaData (org.datanucleus.metadata.KeyMetaData)3 OrderMetaData (org.datanucleus.metadata.OrderMetaData)3 UniqueMetaData (org.datanucleus.metadata.UniqueMetaData)3 Set (java.util.Set)2 AttributeConverter (javax.jdo.AttributeConverter)2 Column (javax.jdo.annotations.Column)2 Extension (javax.jdo.annotations.Extension)2 ForeignKeyAction (javax.jdo.annotations.ForeignKeyAction)2 Persistent (javax.jdo.annotations.Persistent)2