Possible to have immutable JPA entities?
问题 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 a to set a mutator and we get an exception due to a NOT NULL field. 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. Thanks 回答1: If you make your beans immutable then you have to use field level access and this comes with its own