Support logical fields(method @Column)
Supporting methods as write-only fields, the current implementation causes confusion when using properties because the field value is a placeholder.
Or are there other correct ways to implement logical fields that I don’t know? Please let me know.
expect
public class Rectangle {
private int h;
private int w;
@Column
public int area() {
return h * w;
}
}
current
public class Rectangle {
private int h;
private int w;
@AccessType(AccessType.Type.PROPERTY)
private int area;
public int getArea() {
return h * w;
}
}
The write only property would at the very least be constructed as a normal getter:
public int area() {
return h * w;
}
That said, it doesn't work either. :-/
This should work fine with just the annotations, and should not require special forms of method names.
Currently, even if it is a normal getter, it will not take effect if there is no field.
Methods in embedded objects should also support write-only fields, and also support prefixes.
Is there any current plan for this enhancement? @schauder
At present, the processing of some calculated properties is very tricky and very error-prone, because if the fields that the calculated properties depend on change, the fields of the calculated properties must be reassigned. If forgotten, it will be catastrophic. If you use @AccessType(AccessType.Type.PROPERTY), Instead of reassigning a computed property field each time, accidentally using a field instead of a getter method would be disastrous.