Use BeforeConvertCallback to generate entity identifiers.

Related ticket: https://github.com/spring-projects/spring-data-relational/issues/1232
See #636
This commit is contained in:
Mark Paluch
2022-04-27 09:18:16 +02:00
committed by Greg L. Turnquist
parent 7ae3c21718
commit 86e67a483c

View File

@@ -5,7 +5,7 @@ import java.util.UUID;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.relational.core.mapping.event.BeforeSaveCallback;
import org.springframework.data.relational.core.mapping.event.BeforeConvertCallback;
@SpringBootApplication
class IdGenerationApplication {
@@ -15,9 +15,9 @@ class IdGenerationApplication {
}
@Bean
BeforeSaveCallback<StringIdMinion> beforeSaveCallback() {
BeforeConvertCallback<StringIdMinion> beforeSaveCallback() {
return (minion, mutableAggregateChange) -> {
return (minion) -> {
if (minion.id == null) {
minion.id = UUID.randomUUID().toString();
}