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

public class IdentityIdGenerator extends AbstractGenerator implements 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 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

      public GenerationType type()
      Returns IDENTITY GenerationType for further understanding of what type of generator we are dealing with
      Specified by:
      type in interface Generator
      Returns:
      the generation type
    • handle

      public <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. 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 interface Generator
      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

      private void updateEntity(Object entity, Object value)