This repository was archived by the owner on Sep 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
saveAll batch size dynamic configuration #43
Copy link
Copy link
Open
Description
Like in Hibernate, to have the ability to enforce batch sizes limitations from the application.yml file.
Something like this:
neo4j:
uri: bolt://localhost:7687
authentication:
username: neo4j
password: password
minTransactionSize: 5
maxTransactionSize: 50When a batch that is less than or greater than these are trying to operate then raise an exception:
@Repository
@Transactional(readOnly = true)
@API(status = API.Status.STABLE, since = "6.0")
public class SimpleNeo4jRepository<T, ID> implements PagingAndSortingRepository<T, ID>, CrudRepository<T, ID> {
...
@Override
@Transactional
public <S extends T> List<S> saveAll(Iterable<S> entities) {
validateBatchOperationSizeLimitations(entities); // <- Add this
return this.neo4jOperations.saveAll(entities);
}
// Validation method
private void validateBatchOperationSizeLimitations(Iterable<S> entities) {
boolean isMinViolation = this.configuration.minTransactionSize() > entities.size();
boolean isMaxViolation = this.configuration.maxTransactionSize() < entities.size();
if (isMinViolation || isMaxViolation) {
throw new BatchSizeLimitationException();
}
}
Metadata
Metadata
Assignees
Labels
No labels