Package com.onec.spring
Class OnecAfterConvertCallback
java.lang.Object
com.onec.spring.OnecAfterConvertCallback
- All Implemented Interfaces:
org.springframework.data.mapping.callback.EntityCallback<Object>,org.springframework.data.relational.core.mapping.event.AfterConvertCallback<Object>
public class OnecAfterConvertCallback
extends Object
implements org.springframework.data.relational.core.mapping.event.AfterConvertCallback<Object>
Marks freshly-loaded aggregates as not-new so that a subsequent
repository.save(...)
issues an UPDATE rather than an INSERT.
CatalogObject/DocumentObject/AccumulationRecord all implement
Persistable with isNew defaulting to true
(so a brand-new instance inserts). Spring Data JDBC never flips that flag back after reading a row,
so without this callback an entity loaded from the database would still report isNew == true
and save() would attempt to re-INSERT it — causing a duplicate-key error, or a silent no-op
when the INSERT is ignored. Running on AfterConvert (after the row is mapped to an object,
on every load path) is the canonical place to reset it.
-
Constructor Summary
ConstructorsConstructorDescriptionOnecAfterConvertCallback(MetadataRegistry registry, SecretCipher secretCipher) -
Method Summary
-
Constructor Details
-
OnecAfterConvertCallback
-
-
Method Details
-
onAfterConvert
- Specified by:
onAfterConvertin interfaceorg.springframework.data.relational.core.mapping.event.AfterConvertCallback<Object>
-