Skip to content

Latest commit

 

History

History
61 lines (41 loc) · 1.52 KB

BatchProcessing.md

File metadata and controls

61 lines (41 loc) · 1.52 KB

Batch Processing

The batch processing feature in Bibernate facilitates the efficient handling of database operations by minimizing round-trips to the database. This results in improved performance, especially when dealing with large datasets.

saveAll Method

Description:

The saveAll method allows for batch insertion of entities into the database.

Signature:

public<T> void saveAll(Class<T> entityClass,Collection<T> entities);

Example:

List<User> userList= //... create a list of User entities
bibernateSession.saveAll(User.class,userList);

deleteAllById Method

Description:

The deleteAllById method enables batch deletion of entities by their primary keys.

Signature:

public <T> void deleteAllById(Class<T> entityClass, Collection<Object> primaryKeys);

Example:

List<Long> userIdsToDelete = //... create a list of User IDs to delete
bibernateSession.deleteAllById(User.class, userIdsToDelete);

deleteAll Method

Description:

The deleteAll method supports batch deletion of entities based on a collection of entity instances.

Signature:

public <T> void deleteAll(Class<T> entityClass, Collection<T> entities);

Example:

List<User> usersToDelete = //... create a list of User entities to delete
bibernateSession.deleteAll(User.class, usersToDelete);

These batch processing methods provide a convenient way to optimize database operations by grouping them into batches, resulting in improved overall performance.