persistence icon indicating copy to clipboard operation
persistence copied to clipboard

Path.get(PluralAttribute<X, C, E> collection) does not support attributes from "MappedSuperclass"

Open dermoritz opened this issue 4 years ago • 2 comments

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

dermoritz avatar Jan 29 '21 15:01 dermoritz

You mean https://github.com/eclipse-ee4j/jpa-api/issues/108

andyjefferson avatar Jan 30 '21 09:01 andyjefferson

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.

dermoritz avatar Feb 01 '21 07:02 dermoritz

This dupe issue was already fixed by https://github.com/jakartaee/persistence/pull/173.

gavinking avatar Aug 09 '23 18:08 gavinking