'JPA base entity for modifiedBy and modifiedDate attributes
In a spring boot project where I'm using spring data and JPA, all my entities have the modifiedByUser and modifiedDatetime attributes. Since I am being repetitive, I was thinking of creating a base class with those attributes, however I'm not sure if making all the entities extend a base class is a good idea since inheritance comes with its own issues.
I was also thinking in adding JPA entity lifecycle events to calculate the values for the modifiedByUser and modifiedDatetime fields. Is there any other suggested approach?
Solution 1:[1]
As you said modifiedByUser and modifiedDatetime attributes would be repetitive things so you want to make it easy to use so I would suggest you to use the base class extending mechanism.
If you use JPA entity lifecycle events to calculate the values for the modifiedByUser and modifiedDatetime fields then it would be a repetitive things again and this is not the thing what you want.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
