How can I inherit Hibernate filters with annotations?

I am trying to configure a Hibernate filter with annotations. I would like to specify it in the base class and use all subclasses, but whenever I try to enable it, Hibernate does not find the filter. Is it even possible to inherit filter annotations?

+3
source share
3 answers

Do you use the sleep filter directly, or are you expanding the sleep filter for your own purposes? Annotations are not inherited by default in Java, although if you wrote the annotation yourself, and I assume that hibernation did not do this in your annotations, you can specify @Inherited meta information in your annotation to make it inherit, However, this works for type annotations only. In addition, some people write an annotation manager to simulate complete inheritance. You could do something like this, either expand the sleep mode mechanism, or write a preprocessor that adds annotations where they should be inherited.

+2
source

3.5.0 @MappedSuperclass. , : HHH-4332

+3

What John Ellinwood wrote, exactly. This is why @Filteryou must specify in all subclasses, at least in Hibernate Annotations 3.4.0-GA.

In addition, although this may not be obvious, you will need the same annotation for all associated collections of this class if you expect these collections to also be subject to filtering.

0
source

Source: https://habr.com/ru/post/1705532/


All Articles