use of javax.jdo.annotations.Element in project motech by motech.
the class EntityMetadataBuilderImpl method addManyToManyMetadata.
private void addManyToManyMetadata(FieldMetadata fmd, RelationshipHolder holder, EntityDto entity, FieldDto field, Class<?> definition) {
// When using Lists join metadata must be present at two sides of M:N relation
if (!holder.isOwningSide() || holder.isListManyToMany()) {
java.lang.reflect.Field fieldDefinition = FieldUtils.getDeclaredField(definition, field.getBasic().getName(), true);
Join join = fieldDefinition.getAnnotation(Join.class);
Persistent persistent = fieldDefinition.getAnnotation(Persistent.class);
Element element = fieldDefinition.getAnnotation(Element.class);
JoinMetadata jmd = null;
if (join == null) {
jmd = fmd.newJoinMetadata();
}
setTableNameMetadata(fmd, persistent, entity, field, holder, EntityType.STANDARD);
setElementMetadata(fmd, element, holder, entity);
if (join == null || StringUtils.isEmpty(join.column())) {
setJoinMetadata(jmd, fmd, ClassName.getSimpleName(entity.getClassName()).toUpperCase() + ID_SUFFIX);
ForeignKeyMetadata fkmd = getOrCreateFkMetadata(jmd);
fkmd.setName(KeyNames.foreignKeyName(entity.getName(), entity.getId(), field.getBasic().getName(), EntityType.STANDARD));
}
}
}
Aggregations