Transparent persistence lets domain objects participate in application logic without knowing whether their state is temporary or stored in a database. Persistence concerns move into metadata and a generic persistence manager, limiting their effect on the domain model. section 3.2.1 section 10.1
A transparent persistence model aims to preserve ordinary domain programming:
- Implement persistent classes as POJOs without JPA or Hibernate API dependencies, special superclasses, or required interfaces. section 3.2.2
- Create entity instances with the regular Java new operator and reuse them in unit tests or presentation code. section 3.2.2
- Keep complex business logic independent of whether an entity is currently persistent, retrieved, or only held in memory. section 3.2.2 section 10.1
- Accept limited persistence requirements, including interface-typed collections and a database identifier on entity classes. section 3.2.2
Testing Item business logic
An Item object can be created with new Item(...) and its calculateTotalPrice() method can be invoked in a unit test without considering persistence. Database synchronization remains the responsibility of the Jakarta Persistence interfaces and the surrounding persistence context. section 3.2.2 section 10.1
Transparency does not eliminate persistence interaction. Applications still call persistence interfaces to load or store state, and those interactions expose entity states, persistence contexts, managed scope, and units of work. section 10.1
