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

non sequitor picture non sequitor · Oct 19, 2009 · Viewed 20.6k times · Source

What is the difference between the two if any?

Should one or both be used on an entity?

Answer

ChssPly76 picture ChssPly76 · Oct 19, 2009

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