public DirectCollectionMapping addDirectCollectionMapping(String name, String targetTable, String valueColumn, Class<?> valueType, String... fkFieldNames) throws IllegalArgumentException {
if (fkFieldNames == null || getType().getDescriptor().getPrimaryKeyFields().size() != fkFieldNames.length) {
throw new IllegalArgumentException("Invalid FK field names: " + fkFieldNames + " for target: ");
}
DirectCollectionMapping mapping = new DirectCollectionMapping();
mapping.setAttributeName(name);
mapping.setReferenceTableName(targetTable);
mapping.setDirectFieldName(valueColumn);
mapping.setDirectFieldClassification(valueType);
for (int index = 0; index < fkFieldNames.length; index++) {
String targetField = getType().getDescriptor().getPrimaryKeyFields().get(index).getName();
mapping.addReferenceKeyFieldName(fkFieldNames[index], targetField);
}
mapping.useTransparentList();
return (DirectCollectionMapping) addMapping(mapping);
}