liveBook · Manning

Discriminator value

As explained in Java Persistence with Spring Data and Hibernate epub

A discriminator value is the literal value assigned to an entity subtype in an inheritance mapping.

A discriminator value is the literal marker Hibernate uses to identify an entity subtype when an inheritance hierarchy shares one table. The value is stored in an internal discriminator column, not as an entity property; for example, `CC` identifies `CreditCard` rows. section 7.3

Explicit subtype mapping

With `@DiscriminatorColumn(name = "BD_TYPE")` on `BillingDetails`, annotate a concrete subtype as `@DiscriminatorValue("CC")`. Hibernate writes `CC` to `BD_TYPE` and uses `where BD_TYPE='CC'` when querying `CreditCard` entities. Explicit values avoid provider-dependent defaults. section 7.3

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Explains storage, querying, defaults, and the recommendation to declare values explicitly.
Examples
Uses `CC` for `CreditCard` and `BA` for `BankAccount` in the `BILLINGDETAILS` table.
What you can do after
Apply it via JPA or Hibernate annotations to make subtype values predictable across mappings.
How it connects
Connects inheritance mapping with discriminator columns, entity subtypes, and discriminator formulas.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.