Clarifying terminology - What does "hydrating" a JPA or Hibernate entity mean when fetching the entity from the DB

hibernate, java, jpa, lazy-loading, orm

Solution

Yes the definition is correct, the term hydration is a conceptual metaphor used to describe setting the member properties of an object/model, (post-instantiation/creation) with the values from its associated database record.

Its common nomenclature for ORM/Persistence libraries. BizTalk, JPA, Hibernate and Doctrine all use the concept to various degrees, for instance, BizTalk also explicitly defines dehydrated to mean the state where an object/model has been instantiated (created) but not yet hydrated (a required life-cycle state to lazy load and or model self referencing relations)

Some are averse to the terms adoption, arguing that it is redundant, a marketing tool, or disliking terminology overhauls, sighting the adequacy of populated, empty and clear to describe the life-cycle.

Others find the metaphor useful to solve confusion where populated is commonly used to describe a collection's state (as opposed to an object/model) as well.

The term has been in use for years now, more recently being borrowed by JavaScript Frameworks (e.g. React) to describe the distinct but similar concept of integrating server rendered components into client side object models.

Its safe to say, they are here to stay.

Problem

In the context of ORM / Lazy loading of entities, my understanding of the term "Hydration" is as follows: "Hydrating" describes the process of populating some or all of the previously unpopulated attributes of an entity fetched using lazy loading. Eg: class `Author` is loaded from the database: ``` @Entity class Author { @Id long id; List<Book> books; } ``` Initially, the `books` collection is not populated. It is my understanding that the process of loading the `books` collection from the database is referred to as "Hydrating" the collection. Is this definition correct, and is the term common place? Is there another more common term I should be using for this process?

Original source