private JavaTypeMapping addOrderColumn(AbstractMemberMetaData fmd, ClassLoaderResolver clr)
{
Class indexType = Integer.class;
JavaTypeMapping indexMapping = new IndexMapping();
indexMapping.initialize(dba, indexType.getName());
IdentifierFactory idFactory = storeMgr.getIdentifierFactory();
DatastoreIdentifier indexColumnName = null;
ColumnMetaData colmd = null;
// Allow for any user definition in OrderMetaData
OrderMetaData omd = fmd.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 = getFieldMapping(omd.getMappedBy());
if (orderMapping == null)
{
throw new JPOXUserException(LOCALISER.msg("057021",
fmd.getFullFieldName(), omd.getMappedBy()));
}
if (!(orderMapping instanceof IntegerMapping) && !(orderMapping instanceof LongMapping))
{
throw new JPOXUserException(LOCALISER.msg("057022",
fmd.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