Object keyValue = obj.getData().get(getKeyFieldName());
return middleCls.filter(middleField.eq(keyValue)).target(middleField);
}
public void createMiddleClass() throws DBException {
ModelClassBase referenceModelClass = getReferenceClass();
ModelClassBase middleModelClass = getMiddleClass();
ManyReferenceField referenceField = getReverseField();
if (middleModelClass == null) {
middleModelClass = new DynamicModelClass(getMiddleModelName(), middleBaseClass, map("table", getMiddleModelTableName()));
middleModelClass.getManager().addField(
referenceField.getMiddleModelFieldName(),
new ReferenceField(referenceModelClass.getManager().getModel(), map(
"referenceModelName", referenceModelClass.getName(),
"referenceModelKeyName", referenceField.getKeyFieldName(),
"columnName", referenceModelClass.getManager().getTableName().toLowerCase()))
);
middleModelClass.getManager().addField(
getMiddleModelFieldName(),
new ReferenceField(fieldClass, map(
"referenceModelName", manager.getName(),
"referenceModelKeyName", getKeyFieldName(),
"columnName", manager.getTableName().toLowerCase()))
);
middleModelClass.getManager().addField("id", new PrimaryKey());
}
}