use of io.micronaut.data.exceptions.MappingException in project micronaut-data by micronaut-projects.
the class SqlQueryBuilder method resolveJoinTableAssociatedColumns.
@NonNull
private List<String> resolveJoinTableAssociatedColumns(AnnotationMetadata annotationMetadata, boolean associationOwner, PersistentEntity entity, NamingStrategy namingStrategy) {
List<String> joinColumns = getJoinedColumns(annotationMetadata, associationOwner, "referencedColumnName");
if (!joinColumns.isEmpty()) {
return joinColumns;
}
PersistentProperty identity = entity.getIdentity();
if (identity == null) {
throw new MappingException("Cannot have a foreign key association without an ID on entity: " + entity.getName());
}
List<String> columns = new ArrayList<>();
traversePersistentProperties(identity, (associations, property) -> {
String columnName = namingStrategy.mappedName(associations, property);
columns.add(columnName);
});
return columns;
}
Aggregations