In our application, we need to have fields that are assignable only once.
At first we thought of encapsulating the fields and making the setters private. However, some q
You can mark an entity with @Entity(mutable=false)
or @Immutable
annotations for the framework to make use of this fact for performance gain in caching and such. (Hibernate)
Then you can use an immutable wrapper class like this:
public class ImmutableStuff {
private final FooField barValue;
public ImmutableStuff(Stuff stuff) {
barValue = stuff.barValue;
}
public FooField getBarValue(){
return barValue;
}
}