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.
JavaTypeMapping orderMapping = getMemberMapping(omd.getMappedBy());
if (orderMapping == null) {
throw new NucleusUserException(String.format(
"Field \"{0}\" has an <order> defined to be persisted into the columns in the element table for element field \"{1}\". This field is not found in the element class.",
fmd.getFullFieldName(), omd.getMappedBy()));
}
if (!(orderMapping instanceof IntegerMapping) && !(orderMapping instanceof LongMapping)) {
throw new NucleusUserException(
String.format(
"Field \"{0}\" has an <order> defined to be persisted into the column of field \"{1}\". This field is of an invalid type. Must be an int/Integer.",
fmd.getFullFieldName(), omd.getMappedBy()));
}
return orderMapping;
}
String colName;
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