Class NoneIdGenerator
java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.jdbc.identity.AbstractGenerator
io.github.blyznytsiaorg.bibernate.dao.jdbc.identity.NoneIdGenerator
- All Implemented Interfaces:
Generator
Implementation of the insert generation without ID generation in Bibernate.
This generator is responsible for handling entities with their own IDs already set.
This generator is suitable for entities where the IDs are provided, and no generation is needed. The generator operates by inserting entities into the database without attempting to generate IDs during the process.
This class is designed to be used when dealing with entities that have their own unique identifiers specified, and there is no need for the database to generate new IDs during the insertion process.
- Since:
- 1.0
- Author:
- Blyzhnytsia Team
-
Constructor Summary
ConstructorDescriptionNoneIdGenerator
(BibernateDatabaseSettings bibernateDatabaseSettings, List<String> executedQueries) Constructs an NoneIdGenerator 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 insert query using id from the entity.type()
Returns NONE GenerationType for further understanding of what type of generator we are dealing withMethods inherited from class io.github.blyznytsiaorg.bibernate.dao.jdbc.identity.AbstractGenerator
addToExecutedQueries, addUpdatedEntity, getBatchSize, getGeneratedValue, insertManyToManyJoinTable, populatePreparedStatement, populatePreparedStatement, populatePreparedStatement, showSql
-
Constructor Details
-
NoneIdGenerator
public NoneIdGenerator(BibernateDatabaseSettings bibernateDatabaseSettings, List<String> executedQueries) Constructs an NoneIdGenerator 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 NONE GenerationType for further understanding of what type of generator we are dealing with -
handle
Handles the generation of insert query using id from the entity. This method constructs the INSERT query, prepares the statement, populates it with entity values, and executes the batch for improved performance. It also logs executed queries and handles many-to-many join tables.- 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.
-