I work on a large modularized project with many maven modules, and dependency management is quite complex.
In our core module, we have an entity BackOfficeUser with many attributes.
This entity is used in most of the applicative modules.
But one of my module XXX need to enhance the user with a collection of entities UserRule.
What i’d like to know is if it’s possible to subclass the core BackOfficeUser to create an XXXBackOfficeUser in my application, with a new relationship non owned by the entity, which doesn’t need a new column in the core db table of BackOfficeUser.
I know i can create a DAO and call rulesDAO.findByUser(BackOfficeUser user)
But i’d like to know if it’s possible to have instead XXXBackOfficeUser.getRules()
All that without modifying the core BackOfficeUser class which is used by a LOT of other modules, and which is not a MappedSuperClass or anything else but a regular hibernate entity.
It is not possible without modification of BackOfficeUser class, but is possible without modifying table where BackOfficeUser is persisted. Modification needed to the BackOffice class is:
With Hibernate this does not cause additional DTYPE column to be added to the root-table, because Hibernate support joined inheritance without discriminator column. Joined inheritance without discriminator is not portable, because specification does not require support for it. Consequence is that for defining actual type of BackOfficeUser, queries will always be joined to the new table.
Implementation goes roughly as follows: