Parameter names could be used for simpler entity construction through constructors instead of setters, where applicable. It would also enable fully immutable entity classes. Default constructor and setters are a major pain point for many users.
try to and eliminate the requirement for no arg constructor on entities or at least weaken that requirement to specific cases. Construction from both the user code and the hibernate itself would go through user specified constructors. This would enable use cases like enforcing invariants in constructors, immutable entities and in the long run, maybe even support for value types coming in Java 10 that, at least for now, we know will be immutable and won't have a no arg constructor.
By using parameter names and Java 8 API you can, for instance, map those parameter names to fields to find out column mappings and other information required for mapping arguments to parameters.
A similar approach like this is used by jackson-databind with the jackson-module-parameter-names (this will soon be integrated into the jackson-databind itself). Another example, Spring also uses parameter names to map bean names to parameters in constructors. |
|