In the previous chapter, we demonstrated many annotations that defined mapping and associations between objects; most of those are JPA annotations. In this section, we will look at more annotations that affect mapping and associations. Most of these are only available in Hibernate, but we also cover some very useful JPA annotations that you may not have used.
annotations are only available in Hibernate. They are defined to support polymorphism in Java, in the sense that a discriminator column determines the subclass of a parent class (or interface).
For instance, if you have a table with a discriminator column that helps distinguish one class from the other, you can use the
@Any annotation to map the rows to the correct class. We will discuss
@ManyToAny here, as
@Any is well documented in Hibernate API JavaDoc, but in short,
@Any is used for a one-to-one association.