Using Spring Data JPA with Hibernate, are these two annotations interchangeable?
org.hibernate.annotations.Immutableorg.springframework.data.annotation.ImmutableMore specifically, can the Spring annotation replace the Hibernate annotation, to avoid any direct Hibernate dependency in the entity? If not, is there any reason to have both annotations on the same entity?
No, they are not interchangeable.
For Hibernate you need to use the Hibernate one.
If you use Spring Data modules except Spring Data JPA, i.e. those where Spring Data does the persisting itself you need to use the Spring Data annotation.
In both cases the other annotation will be completely ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With