Class PostgresIdentity

java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.jdbc.identity.PostgresIdentity
All Implemented Interfaces:
Identity

public class PostgresIdentity extends Object implements Identity
Implementation of the Identity interface for managing identity-related operations in Bibernate application specific to PostgreSQL databases. It delegates entity-saving operations to different generators based on the GenerationType strategy specified in the entities' annotations. Supports NONE, SEQUENCE, and IDENTITY GenerationType strategies.
Since:
1.0
Author:
Blyzhnytsia Team
  • Field Details

    • generators

      private final List<Generator> generators
      List of generators for handling different GenerationType strategies.
    • bibernateDatabaseSettings

      private final BibernateDatabaseSettings bibernateDatabaseSettings
      The settings for Bibernate database interactions.
  • Constructor Details

    • PostgresIdentity

      public PostgresIdentity(BibernateDatabaseSettings bibernateDatabaseSettings, List<String> executedQueries)
      Constructs a new PostgresIdentity with the given BibernateDatabaseSettings and list of executed queries.
      Parameters:
      bibernateDatabaseSettings - the settings for Bibernate database interactions
      executedQueries - the list to store executed queries, if query collection is enabled
  • Method Details

    • saveWithIdentity

      public <T> void saveWithIdentity(Class<T> entityClass, Collection<T> entities)
      Implements the saveWithIdentity method from the Identity interface. Delegates the entity-saving operation to the appropriate generator based on the GenerationType strategy.
      Specified by:
      saveWithIdentity in interface Identity
      Type Parameters:
      T - the type of entities in the collection
      Parameters:
      entityClass - the class of the entities to be saved
      entities - the collection of entities to be saved
    • getStrategy

      private static GenerationType getStrategy(Class<?> entityClass)
      Retrieves the GenerationType strategy specified in the entity class annotations.
      Parameters:
      entityClass - the class of the entity
      Returns:
      the GenerationType strategy, or GenerationType.NONE if not specified