}
Index idx = clazz.getAnnotation(Index.class);
IndexCollection indexes = clazz.getAnnotation(IndexCollection.class);
EntityType entityType = (EntityType) kunderaMetadata.getApplicationMetadata()
.getMetaModelBuilder(metadata.getPersistenceUnit()).getManagedTypes().get(clazz);
List<String> columnsNameToBeIndexed = new ArrayList<String>();
Map<String, com.impetus.kundera.index.Index> indexedColumnsMap = new HashMap<String, com.impetus.kundera.index.Index>();
if (null != indexes)
{
if (indexes.columns() != null && indexes.columns().length != 0)
{
metadata.setIndexable(true);
for (com.impetus.kundera.index.Index indexedColumn : indexes.columns())
{
if (indexedColumn.type().equals("composite"))
{
// means comma seperated list of columns
metadata.addIndexProperty(
prepareCompositeIndexName(indexedColumn.name(), entityType, metadata),
populatePropertyIndex(indexedColumn.indexName(), indexedColumn.type(), null, null, null));
}
else
{
indexedColumnsMap.put(indexedColumn.name(), indexedColumn);
}
}
}
}
else if (null != idx)
{
boolean isIndexable = idx.index();
if (isIndexable)
{
metadata.setIndexable(isIndexable);
String indexName = idx.name();
if (indexName != null && !indexName.isEmpty())
{
metadata.setIndexName(indexName);
}
if (idx.columns() != null && idx.columns().length != 0)
{
for (String indexedColumn : idx.columns())
{
columnsNameToBeIndexed.add(indexedColumn);
}
}
}
}
else
{
log.debug("@Entity " + clazz.getName() + " will not be indexed for "
+ (indexedColumnsMap.isEmpty() ? "all columns" : indexedColumnsMap));
return;
}
log.debug("Processing @Entity " + clazz.getName() + " for Indexes.");
// scan for fields
Set<Attribute> attributes = entityType.getAttributes();
for (Attribute attrib : attributes)
{
if (!attrib.isAssociation())
{
String colName = attrib.getName();