Add an "InsertOnly" annotation to support a write-once semantic. [DATAJDBC-416]
Tyler K Van Gorder opened DATAJDBC-416 and commented
It would be nice to mark attributes on an entity as "InsertOnly", such that they are included during and insert but excluded from an update. A use-case for such an annotation can be applied to the "created" auditing columns.
You want to ensure the auditing columns are set when the entity is inserted and you want to prevent those same fields from being overwritten during the update.
1 votes, 2 watchers
The annotation should be '@InsertOnlyProperty' modelled after '@ReadOnlyProperty'.
Any implementation would currently only work for Aggregate Root properties. Therefore this has to wait until we have a better way of updating inner entities in place.
@schauder How about adding an annotation such as @Condition when calling save?
class Student {
...
@Condition
String name;
}
UPDATE student
SET ...
WHERE id = :id AND name = :name
@schauder Please consider it
@taeyeon-Kim I'm confused by what the relation to the original issue is. Could you please clarify, or create a separate issue where you explain what the use case for such a construct is?
May be its too late write any suggestion. But let me write my idea about it. What if will be added property ChangeConditionProperty which get array of strings such as "INSERT", "UPDATE". And then from this condition attribute may be included or excluded from an update script. Thanks!