jaco0646
jaco0646

Reputation: 17094

Spring Data JPA Immutable Entity

Using Spring Data JPA with Hibernate, are these two annotations interchangeable?

  1. org.hibernate.annotations.Immutable
  2. org.springframework.data.annotation.Immutable

More 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?

Upvotes: 7

Views: 2693

Answers (1)

Jens Schauder
Jens Schauder

Reputation: 81970

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.

Upvotes: 3

Related Questions