java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.jdbc.identity.AbstractGenerator
io.github.blyznytsiaorg.bibernate.dao.jdbc.identity.NoneIdGenerator
All Implemented Interfaces:
Generator

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

      public GenerationType type()
      Returns NONE 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 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 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.