JPA Core Types
Core Jakarta Persistence (JPA) types provide the foundation for bootstrapping the persistence engine and performing CRUD operations in ObjectDB. These interfaces and classes manage the entity lifecycle, database connections, and transactional contexts within your application.
The following diagram illustrates the core JPA classes, interfaces, and enums, including their dependencies and inheritance relationships.
Bootstrapping and Configuration
Initialize the persistence context and configure the engine using these classes:
The primary bootstrap class. Use its static methods to create an EntityManagerFactory as the first step for accessing your ObjectDB database.
An alternative bootstrap class that offers a programmatic API for configuration. It allows you to configure the persistence unit without using a traditional persistence.xml file.
Entity Lifecycle Management
Manage database connections and entity lifecycles with these interfaces:
A heavyweight factory class responsible for creating EntityManager instances. Create this once during application initialization for each persistence unit (typically for each ObjectDB database) and close it upon shutdown.
The primary interface for performing CRUD operations, building queries, and managing the persistence context. Because it is not thread-safe, you should use a separate instance for each thread to maintain isolated transactional contexts.
Controls resource-local transactions in environments that do not use JTA. Use this interface to explicitly begin, commit, or roll back transactions.
Utilities and Caching
Access metadata, manage schema, and interact with the second-level cache using these utility types:
A utility interface obtained from Persistence. Use it to check the load state of an entity or attribute without triggering lazy loading.
An extended utility interface obtained from EntityManagerFactory. It provides methods to inspect identifiers and version attributes, and access entity content not yet fetched due to lazy loading.
Provides an API for programmatic schema management, such as creating, dropping, or truncating schemas. Use this interface to manipulate database structures at runtime or during testing.
The interface for interacting with the second-level cache. Use it to check if specific entities are cached or to evict data to ensure synchronization with the database.
Bootstrapping Configuration Enums
Configure persistence unit behavior using these enums:
Specifies whether the application uses JTA or resource-local transactions. This setting defines how the persistence unit manages transaction boundaries.
Specifies the caching strategy for entities within the persistence unit. This determines which entities are stored in the second-level cache, such as all entities or only those explicitly marked.
Specifies how the persistence provider utilizes Jakarta Validation. Use this to explicitly enable, disable, or set validation to auto-detection mode.
Direct JDBC Connection Access
The following functional interfaces are part of the JPA specification for direct JDBC connection access, though they are not applicable to ObjectDB:
A functional interface for executing operations that return a value via a JDBC connection.
A functional interface for executing void operations via a JDBC connection.