org.springframework.data.mongodb.core.mapping.event.BeforeConvertCallback Java Examples
The following examples show how to use
org.springframework.data.mongodb.core.mapping.event.BeforeConvertCallback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationConfiguration.java From spring-data-examples with Apache License 2.0 | 5 votes |
/** * Register the {@link BeforeConvertCallback} used to update an {@link ImmutablePerson} before handing over the newly * created instance to the actual mapping layer performing the conversion into the store native * {@link org.bson.Document} representation. * * @return a {@link BeforeConvertCallback} for {@link ImmutablePerson}. */ @Bean BeforeConvertCallback<ImmutablePerson> beforeConvertCallback() { return (immutablePerson, collection) -> { int randomNumber = ThreadLocalRandom.current().nextInt(1, 100); // withRandomNumber is a so called wither method returning a new instance of the entity with a new value assigned return immutablePerson.withRandomNumber(randomNumber); }; }
Example #2
Source File: CallbacksBenchmark.java From spring-data-dev-tools with Apache License 2.0 | 4 votes |
@Bean BeforeConvertCallback<Person> convertCallback() { return new PersonBeforeConvertCallback(); }