Cannot use '@Filter' and '@Embeddable' together

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?

You can put these definitions on the package level i.e. in a file called package-info.java if you want.

But this will only help me to define FilterDefinition and I have to declare the filter on each entity.

Right, and I think that is a good thing, since column names could change from entity to entity through @AttributeOverrides

Well in my case I want to filter on the same columns in different tables, And for that reason I created Embeddable classes, So I was wondering if I could apply filter in my Embaddable classes, so it would be automatically applied to the Entity which Embedded the Embaddable class

I understand what you want, but Hibernate does not support this. I can only assume this is due to the fact, that column names could be overridden at the entity declaration. So you will have to copy the @Filter to every entity, although you can make use of constants to reduce the duplication.

I assumed this will be the case, I was checking if there is any other options available that can be used along with @Embedded so filters could map to the parent entity if such an annotation exist. Guess I have to define it everywhere.