Class BibernateDatabaseSettings

java.lang.Object
io.github.blyznytsiaorg.bibernate.config.BibernateDatabaseSettings

public class BibernateDatabaseSettings extends Object
Configuration class for Bibernate database settings. It provides methods to create a data source, access database properties, and configure various settings.
Since:
1.0
Author:
Blyzhnytsia Team
  • Field Details

  • Constructor Details

    • BibernateDatabaseSettings

      public BibernateDatabaseSettings(Map<String,String> bibernateSettingsProperties)
      Constructs a new BibernateDatabaseSettings instance with the specified Bibernate settings properties and file name.
      Parameters:
      bibernateSettingsProperties - the Bibernate settings properties loaded from a configuration file
  • Method Details

    • setRedisConfiguration

      public void setRedisConfiguration(RedisConfiguration redisConfiguration)
      Sets the Redis configuration for distributed caching.
      Parameters:
      redisConfiguration - the Redis configuration to be set
    • createDataSource

      private TransactionalDatasource createDataSource()
      Creates a Hikari data source using the configured properties.
      Returns:
      the HikariDataSource object
    • isShowSql

      public boolean isShowSql()
      Checks if SQL logging is enabled.
      Returns:
      true if SQL logging is enabled, otherwise false
    • isCollectQueries

      public boolean isCollectQueries()
      Checks if query collection is enabled.
      Returns:
      true if query collection is enabled, otherwise false
    • isFlywayEnabled

      public boolean isFlywayEnabled()
      Checks if Flyway migration is enabled.
      Returns:
      true if Flyway migration is enabled, otherwise false
    • isDDLCreate

      public boolean isDDLCreate()
      Checks if DDL auto creation is enabled.
      Returns:
      true if DDL auto create is enabled, otherwise false
    • isSecondLevelCacheEnabled

      public boolean isSecondLevelCacheEnabled()
      Checks if the second level cache is enabled.
      Returns:
      true if the second level cache is enabled, otherwise false
    • getSecondLevelCacheHost

      public String getSecondLevelCacheHost()
      Gets the host of the second level cache (Redis).
      Returns:
      the host of the second level cache
    • getSecondLevelCachePost

      public int getSecondLevelCachePost()
      Gets the port of the second level cache (Redis).
      Returns:
      the port of the second level cache
    • getBatchSize

      public int getBatchSize()
      Retrieves the batch size configuration for batch processing from the Bibernate settings properties. If the batch size is not explicitly configured, the method returns the default batch size value.
      Returns:
      The configured batch size for batch processing or the default batch size if not explicitly set.
    • getPropertyBoolean

      private boolean getPropertyBoolean(String key, String defaultValue)
      Retrieves a boolean property value from the Bibernate settings.
      Parameters:
      key - the property key
      defaultValue - the default value if the property is not found
      Returns:
      the boolean property value
    • getPropertyString

      private String getPropertyString(String key, String defaultValue)
      Retrieves a String property value from the Bibernate settings.
      Parameters:
      key - the property key
      defaultValue - the default value if the property is not found
      Returns:
      the String property value
    • checkDatabaseSettings

      private void checkDatabaseSettings()
      Checks database settings to ensure they are consistent. If Flyway is enabled and DDL auto is set to "create", it throws a BibernateGeneralException.
      Throws:
      BibernateGeneralException