We have a Media object:
public class Media implements Serializable { @Id @GeneratedValue(strategy = IDENTITY) @Column(insertable = false, updatable = false) private Long id;
}
The expected channel parent selection works in the usual repository methods, but not when using the Specification.
Here is the specification:
public class MediaSpecs { public static Specification<Media> search(final Long partnerId, final Integer width, final Integer height, final String channelType) { return new Specification<Media>() { @Override public Predicate toPredicate(Root<Media> root, CriteriaQuery<?> query, CriteriaBuilder cb) { Predicate restrictions = cb.equal(root.get("archived"), false);
The search specification works correctly when the channelType type is specified, so the connection works. How to indicate that connections should be looked forward to?
I tried adding
Fetch<Media, ChannelType> fetch = root.fetch("channel").fetch("orgChannelType").fetch("type");
Hibernate then throws an exception:
org.hibernate.QueryException: the request was made to retrieve the links, but the owner of the selected association was not present in the selection list [FromElement {explicit rather than combining the collection, selection for retrieval, selection of non-property properties, classAlias โโ= generatedAlias4 ...
How to add associations to the selection list?
Thanks.
source share