Skip to content

Spring Framework Blog

Menu
  • Home
  • Spring
  • Spring Boot
  • About
Menu

JPA Types

Posted on November 16, 2023November 21, 2023 by Armando Marques

Table of Contents

Toggle
  • Loading Types
  • Cascade Types
  • Mapping types
  • Persist vs Merge

Loading Types

Eager – initialization occurs on spot.

Lazy – defers initialization as long as possible.

Cascade Types

ALL – propagates all operations.

PERSIST – propagates persist operation.

MERGE – propagates merge operation.

REMOVE – propagates remove.

REFRESH – propagates refresh and reload of children elements.

DETACH – propagates detachment to children elements.

LOCK – propagates reattachment for children in persistence context.

Mapping types

https://medium.com/@saeiddrv/jpa-hibernate-mapping-types-891686bc6cfd

Persist vs Merge

persist – to add totally new entities

merge – to put back into persistence context if the entity was detached and changed.

Detached object, is an object that has been persisted but then it’s session has been closed.

https://stackoverflow.com/questions/4509086/what-is-the-difference-between-persist-and-merge-in-jpa-and-hibernate?rq=3

  • Spring
  • Documentation
  • References
  • Toc
  • Books
  • Certification
  • AOP
  • Config
  • Java
  • Java core
  • JDBC
  • JPA
  • Rest
  • Security
  • Spring
  • Spring Boot
  • Spring Core
  • Spring Data
  • Spring MVC
  • Spring Rest
  • Spring Security
  • Tests
  • Transactions
  • Uncategorized

Recent Posts

  • Spring Annotations
  • Java Tests
  • Java operators
  • Java versions
  • Java Oracle Licenses
  • Configuration properties
  • MockMvc
  • Spring Security III
  • MVC Controller Method Params
  • JPA Methods
  • Transaction propagation and isolation
  • Spring JDBC
  • Spring Boot Auto-Configuration
  • Spring Resource interface
  • JSR 330 Standard Annotations
  • Spring Aware Interfaces
  • Spring Transactions
  • Spring Boot Core
  • MVC Rest
  • Spring Boot JPA
©2025 Spring Framework Blog | Built using WordPress and Responsive Blogily theme by Superb