Do you have a common base class for Hibernate entities?

后端 未结 5 494
面向向阳花
面向向阳花 2021-02-01 05:51

Do you have a common base class for Hibernate entities, i.e. a MappedSuperclass with id, version and other common properties? Are there any drawbacks?

Example:



        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-01 06:38

    It works well for me too.

    Notice that you can also in this entity add some event listeners / interceptors like the Hibernate Envers one or any custom one according to your need so that you can: - Track all modifications - Know which user made the last modification - Update automatically the last modification - Set automatically the first insertion date And ther stuff like that...

提交回复
热议问题