I have several entity with timestamp and I want to filter each using the timestamp.
I created a Embeddable class to hold creation time and tried to Embed that in each entity
but when applying the filter an exception is thrown with “No such filter configured”
@Embeddable
@Filter(name = START_AND_END_AT_FILTER, condition = "(:start <= start_at and end_at < :end)")
@FilterDef(
name = START_AND_END_AT_FILTER,
parameters = {
@ParamDef(name = START, type = "string"),
@ParamDef(name = END, type = "string")
})
public class StartAndEndAt {
public static final String START_AND_END_AT_FILTER = "start_and_end_at_filter";
public static final String START = "start";
public static final String END = "end";
@Column(updatable = false, insertable = false)
private OffsetDateTime startAt;
@Column(updatable = false, insertable = false)
private OffsetDateTime endAt;
}
@Entity
@Table
public class Session {
@Embedded
private StartAndEndAt startAndEndAt;
}
@Entity
@Table
public class Session {
@Embedded
private StartAndEndAt startAndEndAt;
}
I know If I define the filter on each entity the issue will be fixed, but then I have to manage it in so many places. Is there any way to handle this within the Embeddable class itself?