Limit the number of record from a join

Viewed 2234

I have this entity

@Entity
public class RentAmount {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long rentAmountId;

    private BigDecimal unpaidBalance;

    private BigDecimal cashAdvance;

    private BigDecimal totalRentAmount;

    private LocalDate paymentRentDueDate;

    private LocalDate paymentDueDate;

    @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY)
    @OrderBy
    private Set<RoomPayment> roomPaymentList;

    @OneToOne
    private Lodger lodger;
}

My query

select r from RentAmount r Join fetch r.lodger l join fetch l.bailList b join fetch r.roomPaymentList p where r.paymentRentDueDate <= :date and b.paymentPeriod=:paymentPeriod order by r.rentAmountId

RoomPaymentList can be very huge, i search a way to limit the number of record returned.

Is there a way to limit the number of value from roomPaymentList?

3 Answers
Related