0
Good morning Guys! I have some problems in a list that in some cases do not need to return it completely
@OneToMany(mappedBy="local", cascade=CascadeType.ALL, fetch = FetchType.EAGER)
@OrderBy("dataContagem DESC")
private List<Contagem> contagens;
I have tried using the @Size and @Max validation. I am using Hibernate with the JPA specification. It is possible to perform this limit of the Onetomany list in the JPQL query ?
Not possible. Use Native Query or JPQL.
– renanvm
Ideally you remove the
EAGER
of@OneToMany
and control the number of results manually, with a separate query just to pick up Count, so you make your code much more flexible. TheEAGER
is a "code Smell", avoid using it, prefer to use theLAZY
.– Dherik