I am trying to define @OneToMany with a @JoinFormula as follows:
Code:
@Entity
class Schedule {...}
@Entity
class Activity {
@Id
private Long id;
@Getter
@OneToMany(cascade = CascadeType.ALL)
private Set<Schedule> schedule;
@Getter
@OneToMany(fetch=FetchType.LAZY)
@Fetch(FetchMode.SELECT)
@BatchSize(size=15)
@JoinFormula(value = "SELECT s FROM Schedule s WHERE activity = id AND start > NOW()")
private List<Schedule> futureSchedule;
...
}
Unfortunately, the JoinFormula has no effect and the query is never called. I tried to find documentation on the topic, but could hardly find anything. How can I achieve this behaviour?
Thanks