Limit set size<> with JPA

Asked

Viewed 195 times

2

I’m having a hard time searching Google and I can’t find a solution.

I have a note in JPA with a set<> I want to limit the size of objects inside the set, that is, the code below:

@OneToMany(mappedBy = "pidAplic", cascade = CascadeType.PERSIST)
@OrderBy("data DESC")
@JsonManagedReference
private Set<ExecAplic> execucoes;

He brings a List with several objects I want to limit the size to 30.

1 answer

1

Natively there is still no solution for this.

If you are using Hibernate Session try using @Size or @Batchsize:

@OneToMany(...)
@Size(min=1, max=30)
private List<Carro> carroList;

or

@OneToMany(...)
@BatchSize(size=30)
private List<Carro> carroList;
  • Hello uaiHebert already tried the size and the Batchsize and both did not work

  • But you’re using Session?

  • I am using Hibernate Session

  • And with the size? worked?

  • no, I did a go to treat the results

Browser other questions tagged

You are not signed in. Login or sign up in order to post.