javahibernatejpaentityimmutability

What is the difference between @Immutable and @Entity(mutable=false) when using Hibernate


What is the difference between the two if any?

Should one or both be used on an entity?


Solution

  • For entity there's practically no difference. @Immutable gets priority (that is if you have entity that's annotated both as @Immutable and @Entity(mutable = "true") it is going to be treated as immutable).

    @Immutable can also be used on collections with pretty much the same semantics. Details are here