liveBook · Manning

Transparent persistence

As explained in Java Persistence with Spring Data and Hibernate epub

Transparent persistence is persistence in which application code can work with domain objects without explicitly performing their storage and retrieval operations.

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

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Defines POJO requirements and lifecycle boundaries, but stops short of detailing provider-specific persistence algorithms.
Examples
Uses the Item entity, calculateTotalPrice(), Java object construction, unit tests, and JPA entity constraints.
What it assumes
Assumes basic Java domain objects and introduces persistence concerns through POJOs, metadata, entities, and persistence contexts.
What you can do after
Evaluate/understand business logic independently while recognizing where persistence services and lifecycle management remain necessary.
How it connects
Connects domain models, POJOs, ORM, metadata, entity lifecycle, persistence contexts, and units of work.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.