use of io.micronaut.data.model.jpa.criteria.PersistentAssociationPath in project micronaut-data by micronaut-projects.
the class AbstractPersistentEntityJoinSupport method addJoin.
private <X, Y> PersistentAssociationPath<X, Y> addJoin(String attributeName, io.micronaut.data.annotation.Join.Type type, String alias) {
PersistentProperty persistentProperty = getPersistentEntity().getPropertyByName(attributeName);
if (!(persistentProperty instanceof Association)) {
throw new IllegalStateException("Expected an association for attribute name: " + attributeName);
}
PersistentAssociationPath path = joins.computeIfAbsent(attributeName, a -> createJoinAssociation((Association) persistentProperty, type, alias));
if (type != null && type != io.micronaut.data.annotation.Join.Type.DEFAULT) {
path.setAssociationJoinType(type);
}
if (alias != null) {
path.setAlias(alias);
}
return (PersistentAssociationPath<X, Y>) path;
}
use of io.micronaut.data.model.jpa.criteria.PersistentAssociationPath in project micronaut-data by micronaut-projects.
the class Joiner method visitJoins.
private void visitJoins(Set<? extends jakarta.persistence.criteria.Join<?, ?>> joins) {
for (jakarta.persistence.criteria.Join<?, ?> join : joins) {
if (join instanceof PersistentAssociationPath) {
PersistentAssociationPath persistentAssociationPath = (PersistentAssociationPath) join;
if (persistentAssociationPath.getAssociationJoinType() == null) {
continue;
}
joinIfNeeded(persistentAssociationPath, false);
visitJoins(join.getJoins());
}
}
}
use of io.micronaut.data.model.jpa.criteria.PersistentAssociationPath in project micronaut-data by micronaut-projects.
the class SourcePersistentEntityPath method get.
@Override
default <Y> PersistentPropertyPath<Y> get(String attributeName) {
SourcePersistentProperty property = getPersistentEntity().getPropertyByName(attributeName);
if (property == null) {
throw new IllegalStateException("Cannot query entity [" + getPersistentEntity().getSimpleName() + "] on non-existent property: " + attributeName);
}
if (this instanceof PersistentAssociationPath) {
PersistentAssociationPath<?, ?> associationPath = (PersistentAssociationPath) this;
List<Association> associations = associationPath.getAssociations();
List<Association> newAssociations = new ArrayList<>(associations.size() + 1);
newAssociations.addAll(associations);
newAssociations.add(associationPath.getAssociation());
return new SourcePersistentPropertyPathImpl<>(this, newAssociations, property);
}
return new SourcePersistentPropertyPathImpl<>(this, Collections.emptyList(), property);
}
Aggregations