Limit set size with JPA

2

I'm having trouble finding Google and have not found a solution.

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

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

It brings a List with multiple objects I want to limit the size to 30 .

    
asked by anonymous 14.04.2014 / 22:11

1 answer

1

Natively there is still no solution for this.

If you are using the Hibernate Session try using the @Size or @BatchSize:

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

or

@OneToMany(...)
@BatchSize(size=30)
private List<Carro> carroList;
    
14.04.2014 / 23:45