This is similar to ManyToMany, not Many. Users can have multiple tags, and a tag can be associated with multiple users?
You need only such a superclass if you want to relate to a tag in one collection containing each object tagged with this tag. Do you have a requirement for the tag.getOneGiantCollectionOfEveryTaggedEntity() method?
Since the marked objects do not seem to have anything in common, does such a collection really have any meaning in your application domain? Perhaps it can also be quite large, and not the fact that you really want to work with object relationships. From a practical point of view, not knowing about your use case, it seems that tag.getTaggedUsers() , tag.getTaggedPosts() , etc. More useful.
Sorry, I think I am asking more questions than giving answers, but it is not clear that you want your final domain to look like this :)
edit:
Perhaps the actual answer then to the question asked is simply "No, Hibernate will not display to you an unprocessed collection of types that do not have a common ancestor that simply has foreign keys to your entity with everyone." You do not have to impose a “fake” superclass on your entities, but if you do not, you will have to create a join table.
.
Affe
source share