Automated persistence delegates low-level database work to a persistence solution, reducing the need to write SQL statements or use the JDBC API directly. The solution combines domain metadata, a persistence layer, and a persistence mechanism. section 3.2.2
Automation works alongside transparent persistence. Transparent persistence keeps domain classes independent of the persistence mechanism, while automation removes mechanical database tasks from application code. The two goals reduce persistence-related leakage without making the solution completely invisible. section 3.2.2 section 3.2.1
Automated persistence commonly provides these application-level consequences:
- Keeps complex business logic from managing the persistence state of entity instances during ordinary execution. section 3.2.2
- Allows persistent classes to avoid direct runtime dependencies on Jakarta Persistence or Hibernate APIs. section 3.2.2
- Supports ordinary Java construction and reuse of persistent classes in unit tests or presentation code. section 3.2.2
- Still imposes framework requirements, so automation does not mean that persistence concerns disappear entirely. section 3.2.2
Using a persistent domain class outside persistence
An Item domain object can be created with the regular Java new operator and used in a unit test for shipping cost and tax without loading it from or storing it in a database. Persistence remains external to the object, while the persistence solution handles database interaction elsewhere. section 3.2.2 section 3.2.1
