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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations