persistence
persistence copied to clipboard
Path.get(PluralAttribute<X, C, E> collection) does not support attributes from "MappedSuperclass"
I have a Entity hierarchy like this:
@MappedSuperclass
@Data
public class SomeEntityBase {
@Id
@GeneratedValue
private Long id;
@ElementCollection
private Set<String> tags;
@Column
private String name;
}
@Entity
@Data
@EqualsAndHashCode(callSuper = true)
public class SomeEntity extends SomeEntityBase {
}
I am querying the "SomeEntity" entities using criteria API and Metamodel. I put predicates into a class to render them reusable: This
public Predicate find(SingularAttribute<? super T, String> attribute, String y) {
return cB.equal(root.get(attribute), y);
}
.. works fine but..
public Predicate findEmpty(SetAttribute<? super T, String> attribute) {
return cB.isEmpty(root.get(attribute));
}
..is not compiling because the method
<E, C extends java.util.Collection<E>> Expression<C> get(PluralAttribute<X, C, E> collection);
Does not support ? super X
and thus does not support PluralAttribute that are inherited from MappedSuperclass.
For SingularAttribute it look like this:
<Y> Path<Y> get(SingularAttribute<? super X, Y> attribute);
The question is why or can you please just close this gap?
A similar problem is described here: https://github.com/eclipse-ee4j/jpa-api/issues/112
You mean https://github.com/eclipse-ee4j/jpa-api/issues/108
no - i just didn't found #108. This seems to be a duplicate then. #112 is just a similar problem that seem to be ignored too.
This dupe issue was already fixed by https://github.com/jakartaee/persistence/pull/173.