public Object getAssociationFrom(Object entity) throws Exception {
return getter.invoke(entity);
}
public void setById(ObjectContext context, Object entity, Object foreignId) throws Exception {
IdCoder idCoder = new IdCoder(context.getEntityResolver());
ObjectId objectId = idCoder.getObjectId(String.valueOf(foreignId));
ObjectIdQuery query = new ObjectIdQuery(objectId);
List<?> list = context.performQuery(query);
Object newForeignObject = list.size() == 0 ? null : list.get(0);
setter.invoke(entity, newForeignObject);