Answer the question
In order to leave comments, you need to log in
How to select a list of entities with a custom set of attributes via the Criteria API if the entity has an associated collection of other entities?
Hello. There is an entity in which one of the fields is a collection of other entities:
class UserEntity {
private Long id;
private String name;
private Set<GroupEntity> groups;
private byte[] avatar;
//....
}
Criteria API
, and not all fields need to be selected (one field must be excluded - avatar
). But the field with the collection of entities must be included in the selection. Answer the question
In order to leave comments, you need to log in
The question is not clear. If CriteriaApi can get a stream of arbitrary objects (UserEntity), then
you can always apply the map method to the stream and take only the required stream of fields.
.stream().map(userEntity -> userEntity.getAvatar)....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question