Search in sources :

Example 26 with IndexMetaData

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

the class JoinMetadataImpl method getIndexMetadata.

/* (non-Javadoc)
     * @see javax.jdo.metadata.JoinMetadata#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 27 with IndexMetaData

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

the class JDOAnnotationUtils method getIndexMetaData.

/**
 * Convenience method to create an IndexMetaData from the annotations data.
 * @param name Name of the constraint
 * @param table Name of the table (optional)
 * @param unique Whether the constraint is unique
 * @param fields Fields to apply the constraint across (optional)
 * @param columns Columns to apply the constraint across (optional)
 * @return The IndexMetaData
 */
public static IndexMetaData getIndexMetaData(String name, String table, String unique, String[] fields, Column[] columns) {
    IndexMetaData idxmd = new IndexMetaData();
    idxmd.setName(name);
    idxmd.setTable(table);
    if (!StringUtils.isWhitespace(unique)) {
        idxmd.setUnique(Boolean.valueOf(unique));
    }
    if (fields != null && fields.length > 0) {
        for (int j = 0; j < fields.length; j++) {
            idxmd.addMember(fields[j]);
        }
    }
    if (idxmd.getNumberOfMembers() == 0 && columns != null && columns.length > 0) {
        for (int j = 0; j < columns.length; j++) {
            idxmd.addColumn(columns[j].name());
        }
    }
    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