Search code examples
javajpadata-access-layer

Who specifies which (if any) data access layer pattern(s) are used in JPA?


I know some data access layer patterns like:

  • Table data gateway
  • Row data gateway
  • Active record
  • Data mapper
  • ...

JPA is a specification that describes management of relational data in javaee applications - https://en.wikipedia.org/wiki/Jakarta_Persistence

As "management" of relational data i imagine CRUD operations.

JPA has to be implemented. These implementations are for example: EclipseLink, Hibernate, Apache OpenJPA etc.

So, when JPA has to be implemented, it describes management of relational data and data are accessed somehow using JPA, who specifies which (if any) data access layer pattern(s) are used? JPA or implementors?


Solution

    • Generally, a standard (such as JPA) will generally avoid dictating implementation decisions and instead dictate required behaviors expected of implementations.
    • JPA is a data access pattern, somewhere between a database gateway (EntityManager) and a data mapper. Because JPA presents managed Entities to core code, realize that database interactions aren't necessarily restricted to a data access layer: records with implicit updates and (possibly) implicit queries for sub records.

    I encourage anyone to seek to understand the pattern that JPA is - it is an interesting one. Not universal (are there any universal data access patterns?), but a terrific tool to have in your toolbox.