Class Persistent

java.lang.Object
io.github.blyznytsiaorg.bibernate.Persistent

public class Persistent extends Object
The Persistent class provides methods for configuring and creating Bibernate entity managers, stateless sessions, and enabling Flyway migrations and Redis caching. It allows for both default and external configurations, enabling flexibility in setting up the persistence layer.
Since:
1.0
Author:
Blyzhnytsia Team
See Also:
  • Field Details

    • bibernateDatabaseSettings

      private final BibernateDatabaseSettings bibernateDatabaseSettings
    • entitiesPackageName

      private final String entitiesPackageName
  • Constructor Details

    • Persistent

      public Persistent(String entitiesPackageName, Map<String,String> externalBibernateSettings)
      Constructs a Persistent instance with external Bibernate settings and the entities package name.
      Parameters:
      entitiesPackageName - the package name where entities are located
      externalBibernateSettings - the external Bibernate settings
    • Persistent

      public Persistent(String entitiesPackageName, String configFileName)
      Constructs a Persistent instance with external Bibernate settings and the entities package name and a custom config file.
      Parameters:
      entitiesPackageName - the package name where entities are located
      configFileName - the configuration file name
      Throws:
      NullPointerException - if any of the arguments is null
  • Method Details

    • withDefaultConfiguration

      public static Persistent withDefaultConfiguration(String entitiesPackageName)
      Constructs a Persistent instance with default configuration.
      Parameters:
      entitiesPackageName - the package name where entities are located
      Returns:
      a Persistent instance with default configuration
    • withExternalConfiguration

      public static Persistent withExternalConfiguration(String entitiesPackageName, Map<String,String> externalBibernateSettings)
      Constructs a Persistent instance with external configuration.
      Parameters:
      entitiesPackageName - the package name where entities are located
      externalBibernateSettings - the external Bibernate settings
      Returns:
      a Persistent instance with external configuration
    • withExternalConfiguration

      public static Persistent withExternalConfiguration(String entitiesPackageName, String configFileName)
      Constructs a Persistent instance with external configuration.
      Parameters:
      entitiesPackageName - the package name where entities are located
      configFileName - the configuration file name
      Returns:
      a Persistent instance with external configuration and a custom data source
    • createBibernateEntityManager

      public BibernateEntityManagerFactory createBibernateEntityManager()
      Creates a new instance of BibernateEntityManagerFactory.
      Returns:
      a new instance of BibernateEntityManagerFactory
    • enableFlyway

      private FlywayConfiguration enableFlyway()
      Enables Flyway configuration.
      Returns:
      a new instance of FlywayConfiguration
    • enabledRedisConfiguration

      private RedisConfiguration enabledRedisConfiguration()
      Enables Redis configuration.
      Returns:
      a new instance of RedisConfiguration
    • processDDLConfiguration

      private DDLConfiguration processDDLConfiguration()
      Processes DDL configuration for the specified package.
      Returns:
      a new instance of DDLConfiguration
    • createStatelessSession

      public StatelessSession createStatelessSession()
      Creates a new stateless session.
      Returns:
      a new instance of StatelessSession