Class IdentityIdGenerator
java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.jdbc.identity.AbstractGenerator
io.github.blyznytsiaorg.bibernate.dao.jdbc.identity.IdentityIdGenerator
- All Implemented Interfaces:
Generator
Implementation of the identity-based ID generator in Bibernate.
This generator is responsible for handling entities with identity-based generation of primary key values. This IdentityIdGenerator generator anticipates that the identifier will be generated through an INSERT operation into the table.
- Since:
- 1.0
- Author:
- Blyzhnytsia Team
-
Constructor Summary
ConstructorDescriptionIdentityIdGenerator
(BibernateDatabaseSettings bibernateDatabaseSettings, List<String> executedQueries) Constructs an IdentityIdGenerator with the specified Bibernate database settings and a list to store executed queries. -
Method Summary
Modifier and TypeMethodDescription<T> void
handle
(Class<T> entityClass, Collection<T> entities, DataSource dataSource) Handles the generation of identity-based primary keys for a collection of entities and inserts the entities into the database using batch processing.type()
Returns IDENTITY GenerationType for further understanding of what type of generator we are dealing withprivate void
updateEntity
(Object entity, Object value) Methods inherited from class io.github.blyznytsiaorg.bibernate.dao.jdbc.identity.AbstractGenerator
addToExecutedQueries, addUpdatedEntity, getBatchSize, getGeneratedValue, insertManyToManyJoinTable, populatePreparedStatement, populatePreparedStatement, populatePreparedStatement, showSql
-
Constructor Details
-
IdentityIdGenerator
public IdentityIdGenerator(BibernateDatabaseSettings bibernateDatabaseSettings, List<String> executedQueries) Constructs an IdentityIdGenerator with the specified Bibernate database settings and a list to store executed queries.- Parameters:
bibernateDatabaseSettings
- The database settings for Bibernate.executedQueries
- The list to store executed queries.
-
-
Method Details
-
type
Returns IDENTITY GenerationType for further understanding of what type of generator we are dealing with -
handle
Handles the generation of identity-based primary keys for a collection of entities and inserts the entities into the database using batch processing. Gets generated id from the database and sets it to the entity. If the method will be performed in transaction then id will be cleaned up from the entity in case of rollback.- Specified by:
handle
in interfaceGenerator
- Type Parameters:
T
- The type of entities in the collection.- Parameters:
entityClass
- The class of the entities being handled.entities
- The collection of entities for which primary keys are generated.dataSource
- The data source for obtaining a database connection.
-
updateEntity
-