Categories
java spring spring-mvc

Immutable objects and Spring/Spring MVC: the right choice?

I usually try to design my classes as immutable classes, so I have a lot of advantages in terms of coding stress.

But working with Spring, I sometimes notice that the framework “discourages” this kind of design in most cases, in favour of classic JavaBeans design: default constructor + getters/setters.

I really don’t like JavaBean designed objects because of their insane mutability.
So I’m wondering if I’m missing something…

I try to keep my classes design as elegant and reusable as possible, but a framework requires to change this design or allow it in a difficult way…

What’s wrong with this?