this.field = field;
this.daoFactory = daoFactory;
//Validate linkTable name
ManyToMany localAnnotation = field.getAnnotation(ManyToMany.class);
this.linkTable = localAnnotation.linkTable();
//Get remote field
Field matchingRemoteField = null;
Field[] fields = remoteClass.getDeclaredFields();
for(Field remoteField : fields){
if(ReflectionUtils.getGenericlyTypeCount(remoteField) == 1 && ReflectionUtils.getGenericType(remoteField).equals(beanClass) && remoteField.isAnnotationPresent(DAOManaged.class) && remoteField.isAnnotationPresent(ManyToMany.class) && remoteField.getAnnotation(ManyToMany.class).linkTable().equals(linkTable)){
matchingRemoteField = remoteField;
break;
}
}
if(matchingRemoteField == null){
throw new RuntimeException("Unable to to find corresponding @ManyToMany field in " + remoteClass + " while parsing field " + field.getName() + " in " + beanClass);
}
//Get remote annotation
ManyToMany remoteAnnotation = matchingRemoteField.getAnnotation(ManyToMany.class);
//Get local key field
this.localKeyField = getKeyField(localAnnotation, beanClass, field);
//Get local localColumn name