Does Spring Data JDBC have anything similar to @PostLoad
and @PrePersist
from Spring Data JPA?
Asked
Active
Viewed 138 times
1

Bit Wise
- 29
- 4
1 Answers
2
With Spring Data JDBC you currently can't annotate the entity directly. But there are life cycle listeners and callbacks that you can use for the same purpose.
One of the examples given:
@Component
class UserCallbacks implements BeforeConvertCallback<User>,
BeforeSaveCallback<User> {
@Override
public Person onBeforeConvert(User user) {
return // ...
}
@Override
public Person onBeforeSave(User user) {
return // ...
}
}

Jens Schauder
- 77,657
- 34
- 181
- 348
-
Thank you. One suggestion regarding the documentation: please add an expand/collapse button next to each chapter name in the documentation (table of contents). Since the Preface chapter was expanded by default, I haven't noticed other chapters were expandable. – Bit Wise Feb 17 '23 at 16:29