|
Consider the below field declaration:
@Generated(value = GenerationTime.ALWAYS) @Temporal(TemporalType.TIMESTAMP) @ColumnTransformer(write="COALESCE(CURRENT_TIMESTAMP, ?)") private Date modifiedDate;
The expectation from @Generated annotation is that it will read database-generated values after a put() operation. But in PropertyBinder.makeProperty() method (Hibernate 4.1.7 version) and PropertyBinder.determineValueGenerationStrategy() method on Github, the insertable and updatable flags are set to false without giving any consideration to @ColumnTransformer write attribute.
If property.getAnnotation(ColumnTransformer.class) is checked in the above methods, behavior of Generated annotation will fall in line with users' expectations.
Optionally, it may be desirable if Generated annotation also accepts the flags insertable and updatable. This way users can control the behavior much easily.
|