In our Hibernate project, the entities are coded using the Java beans pattern. There's quite a few spots in our code where someone has forgotten to set a mutator and we get an exception due to a NOT NULL
constraint.
Is anyone using a builder to construct their entities or making them immutable?
I'm trying to find an effective pattern that is not in the style of the Java beans pattern.
If you make your beans immutable then you have to use field level access and this comes with its own set of problems as discussed thoroughly here. The approach we took is to have a Builder/Factory enforcing/validating the requiredness etc rules for us.