Class indexType = Integer.class;
JavaTypeMapping indexMapping = new IndexMapping();
indexMapping.initialize(storeMgr, indexType.getName());
indexMapping.setMemberMetaData(mmd);
indexMapping.setDatastoreContainer(this);
IdentifierFactory idFactory = storeMgr.getIdentifierFactory();
DatastoreIdentifier indexColumnName = null;
ColumnMetaData colmd = null;
// Allow for any user definition in OrderMetaData
OrderMetaData omd = mmd.getOrderMetaData();
if (omd != null)
{
colmd = (omd.getColumnMetaData() != null && omd.getColumnMetaData().length > 0 ? omd.getColumnMetaData()[0] : null);
if (omd.getMappedBy() != null)
{
// User has defined ordering using the column(s) of an existing field.
state = TABLE_STATE_INITIALIZED; // Not adding anything so just set table back to "initialised"
JavaTypeMapping orderMapping = getMemberMapping(omd.getMappedBy());
if (orderMapping == null)
{
throw new NucleusUserException(LOCALISER.msg("057021",
mmd.getFullFieldName(), omd.getMappedBy()));
}
if (!(orderMapping instanceof IntegerMapping) && !(orderMapping instanceof LongMapping))
{
throw new NucleusUserException(LOCALISER.msg("057022",
mmd.getFullFieldName(), omd.getMappedBy()));
}
return orderMapping;
}
String colName = null;
if (omd.getColumnMetaData() != null && omd.getColumnMetaData().length > 0 && omd.getColumnMetaData()[0].getName() != null)
{
// User-defined name so create an identifier using it
colName = omd.getColumnMetaData()[0].getName();
indexColumnName = idFactory.newDatastoreFieldIdentifier(colName);
}
}
if (indexColumnName == null)
{
// No name defined so generate one
indexColumnName = idFactory.newForeignKeyFieldIdentifier(mmd, null, null,
storeMgr.getNucleusContext().getTypeManager().isDefaultEmbeddedType(indexType), FieldRole.ROLE_INDEX);
}
DatastoreField column = addDatastoreField(indexType.getName(), indexColumnName, indexMapping, colmd);
if (colmd == null || (colmd != null && colmd.getAllowsNull() == null) ||