| Ko

Complete Guide to First-Level and Second-Level Cache

History and Concepts of Hibernate Cache Architecture Hibernate was designed with caching mechanisms as a core feature for performance optimization from when Gavin King first developed it in 2001. Since then, Hibernate’s cache architecture has evolved into a two-level hierarchical structure called first-level cache and second-level cache, minimizing database access and maximizing application performance. The first-level cache is a mandatory feature that has existed since Hibernate’s early versions along with Session (now EntityManager). The persistence context itself serves as the first-level cache, guaranteeing entity identity within transactions and serving as the foundation for Dirty Checking. ...

June 8, 2024 · 9 min · 1744 words · In-Jun

Complete Guide to Persistence Context

Concept and History of Persistence Context The Persistence Context is an environment for permanently storing entities. It’s a core JPA concept that manages entity lifecycles between the application and database while providing various optimization features. This concept was first introduced under the name “Session” when Gavin King developed Hibernate in 2001. Hibernate’s Session abstracted database connections, tracked entity object states, and provided a consistent data view within transactions. When JPA 1.0 standardized Hibernate in 2006, this concept was reformulated as Persistence Context and EntityManager. ...

June 8, 2024 · 7 min · 1286 words · In-Jun

Complete Guide to Dirty Checking

Concept and History of Dirty Checking Dirty Checking is one of Hibernate’s core features that automatically detects changes to entities managed by the persistence context and reflects them in the database. This concept was introduced as a core implementation of Transparent Persistence when Gavin King first developed Hibernate in 2001. It was designed so that the database would automatically update just by changing an object’s state, without developers writing explicit UPDATE statements. ...

June 8, 2024 · 7 min · 1422 words · In-Jun

Understanding the N+1 Problem

What is the N+1 Problem? The N+1 problem is a common performance issue in Object-Relational Mapping (ORM) where N additional queries are executed when retrieving associated entities. As a result, the total number of queries becomes N+1. When the number of queries increases, database communication multiplies, network round-trip time grows, and there is a risk of database connection pool exhaustion, which can significantly degrade performance. History and Background of the N+1 Problem The N+1 problem emerged alongside ORM frameworks and is particularly common when using Lazy Loading strategies in Hibernate and JPA. ORM frameworks adopt lazy loading as the default strategy to handle data in an object-oriented manner by deferring the loading of associated entities until needed. This approach has advantages such as preventing unnecessary data loading and improving initial loading speed. However, when developers access associated entities inside loops without recognizing the relationships, individual queries are executed for each entity, causing the N+1 problem. This has remained a critical performance issue that developers must be aware of from the early versions of Hibernate to the present. ...

June 8, 2024 · 7 min · 1373 words · In-Jun

Lazy Loading VS Eager Loading

History and Necessity of Loading Strategies ORM (Object-Relational Mapping) frameworks emerged to solve the impedance mismatch between object-oriented programming and relational databases. During this process, how to efficiently load entities with associations became a critical challenge. Early ORM implementations used immediate loading for all associated entities, which caused performance degradation by loading unnecessary data into memory. Hibernate introduced a proxy-based lazy loading mechanism to solve this problem. Hibernate has continuously improved loading strategies since its initial release in 2001. While early versions only supported simple lazy loading, later versions added various optimization techniques such as fetch join, batch fetching, and subselect fetching. These features were included in the JPA (Java Persistence API) 1.0 standard when it was released in 2006. Through JPA 2.0 (2009) and JPA 2.1 (2013), declarative fetch strategies like @EntityGraph were added, enabling more sophisticated control over associated entity loading. Today, the JPA standard and Hibernate implementation continue to evolve together, providing developers with various options. ...

June 8, 2024 · 8 min · 1698 words · In-Jun

Complete Guide to JPA Entity Lifecycle

What is Entity Lifecycle In JPA (Java Persistence API), the entity lifecycle refers to the series of state changes an entity object goes through from creation to destruction. This concept was first defined in the JPA 1.0 specification released with Java EE 5 in 2006, designed around the persistence context that standardized Hibernate’s Session concept. Entities are classified into four states based on whether they are managed by the persistence context and their synchronization status with the database: Transient, Managed, Detached, and Removed. Each state transitions through EntityManager methods such as persist(), merge(), detach(), and remove(). ...

June 8, 2024 · 9 min · 1827 words · In-Jun

Complete Guide to EntityManager

History and Concept of EntityManager EntityManager is the core interface of Java Persistence API (JPA), first defined in the EJB 3.0 specification released as part of JSR 220 in 2006. It was designed to standardize Hibernate’s Session interface and provide a vendor-independent persistence management API. The Session concept introduced by Gavin King in 2001 when developing Hibernate was an innovative approach that abstracted database connections and tracked entity object states. JPA standardized this idea, reformulated it as EntityManager, and enabled the same interface to be used across all JPA implementations (Hibernate, EclipseLink, OpenJPA). ...

June 7, 2024 · 8 min · 1530 words · In-Jun

Complete Guide to Spring Data JPA vs JPA Differences

JPA’s Origins and History JPA (Java Persistence API) was first announced on May 11, 2006, through Java Community Process JSR 220 as part of the EJB 3.0 specification. It standardized Hibernate’s core concepts to address the complexity, heavy structure, and container dependency issues of existing EJB 2.x Entity Beans. EJB 2.x Entity Beans required writing Home Interface, Remote Interface, and Bean Class, along with managing complex XML descriptors, which significantly reduced development productivity and made testing difficult. ...

June 7, 2024 · 8 min · 1555 words · In-Jun

What is ORM (Object-Relational Mapping)?

History and Background of ORM ORM (Object-Relational Mapping) is a technology that automatically maps objects in object-oriented programming languages to tables in relational databases. It emerged in the early 1990s when object-oriented programming became mainstream, designed to solve the Object-Relational Impedance Mismatch between objects and tables. The first commercial ORM tool was TOPLink (now Oracle TopLink) in 1994, originally developed for Smalltalk environments before Java. It was later ported to Java in 1996, contributing to the spread of ORM concepts in the enterprise Java ecosystem. ...

May 15, 2024 · 7 min · 1313 words · In-Jun
[email protected]