Class Persistent
java.lang.Object
io.github.blyznytsiaorg.bibernate.Persistent
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 Summary
-
Constructor Summary
ConstructorDescriptionPersistent
(String entitiesPackageName, String configFileName) Constructs a Persistent instance with external Bibernate settings and the entities package name and a custom config file.Persistent
(String entitiesPackageName, Map<String, String> externalBibernateSettings) Constructs a Persistent instance with external Bibernate settings and the entities package name. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new instance ofBibernateEntityManagerFactory
.Creates a new stateless session.private RedisConfiguration
Enables Redis configuration.private FlywayConfiguration
Enables Flyway configuration.private DDLConfiguration
Processes DDL configuration for the specified package.static Persistent
withDefaultConfiguration
(String entitiesPackageName) Constructs a Persistent instance with default configuration.static Persistent
withExternalConfiguration
(String entitiesPackageName, String configFileName) Constructs a Persistent instance with external configuration.static Persistent
withExternalConfiguration
(String entitiesPackageName, Map<String, String> externalBibernateSettings) Constructs a Persistent instance with external configuration.
-
Field Details
-
bibernateDatabaseSettings
-
entitiesPackageName
-
-
Constructor Details
-
Persistent
Constructs a Persistent instance with external Bibernate settings and the entities package name.- Parameters:
entitiesPackageName
- the package name where entities are locatedexternalBibernateSettings
- the external Bibernate settings
-
Persistent
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 locatedconfigFileName
- the configuration file name- Throws:
NullPointerException
- if any of the arguments is null
-
-
Method Details
-
withDefaultConfiguration
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 locatedexternalBibernateSettings
- 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 locatedconfigFileName
- the configuration file name- Returns:
- a Persistent instance with external configuration and a custom data source
-
createBibernateEntityManager
Creates a new instance ofBibernateEntityManagerFactory
.- Returns:
- a new instance of
BibernateEntityManagerFactory
-
enableFlyway
Enables Flyway configuration.- Returns:
- a new instance of
FlywayConfiguration
-
enabledRedisConfiguration
Enables Redis configuration.- Returns:
- a new instance of
RedisConfiguration
-
processDDLConfiguration
Processes DDL configuration for the specified package.- Returns:
- a new instance of
DDLConfiguration
-
createStatelessSession
Creates a new stateless session.- Returns:
- a new instance of
StatelessSession
-