|
Tim Whitbeck Your's is actually a separate discussion. The discussion here is specifically about understanding that there is a JavaBean pattern in the class; even though the AccessType is defined as FIELD, understanding that there is a getter too, and that calling the getter is safe because it refers to the identifier (which the proxy already has access to).
This is not about general "do init or dont" solutions. It is very specifically about identifiers.
BTW, there is a start to this is on master for 5.0. The idea there so far is to allow the users break from strict JPA and tell Hibernate to allow @Access(PROPERTY) on a field, such that the AccessType just names the runtime access strategy. That does require there to be a setter, yes. Yet, another option if you want to not have the setter is to use a customer org.hibernate.property.PropertyAccessor strategy. All of this is covered in the new topical guide: https://github.com/hibernate/hibernate-orm/blob/master/documentation/src/main/asciidoc/topical/accesstype/AccessType.adoc
|