JPA Inheritance Strategies: Single Table, Joined, Per Class
Compare the three JPA inheritance strategies and @MappedSuperclass with entity examples, resulting tables and guidance on when to use each.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
Compare the three JPA inheritance strategies and @MappedSuperclass with entity examples, resulting tables and guidance on when to use each.
Apache Camel maps Enterprise Integration Patterns to Java DSL steps in a RouteBuilder. See working routing, transformation, aggregation and error handling examples.
RouteBuilder is the base class for defining Apache Camel routes in Java. You override configure() to say where messages come from, how they change and where they go.
@Inheritance chooses how JPA stores an entity class hierarchy. Compare the three strategies, their schemas and when to use each.
Compare the JPA inheritance strategies SINGLE_TABLE, JOINED and TABLE_PER_CLASS, plus @MappedSuperclass, with working jakarta.persistence examples.
@Version turns on optimistic locking in JPA. Learn how the version check works in SQL, how to handle the exception in Spring, and when to use pessimistic locks instead.
Use @Version for optimistic locking in JPA: how the version column works, how to handle conflicts in Spring Boot and when to choose pessimistic locks.
@AuditOverride belongs to Hibernate Envers, not JPA. It controls whether inherited or embedded properties join the revision history. See examples and how it differs from Spring Data auditing.
Use Hibernate Envers to keep a complete history of every entity change, record who made it and read any past version of a row.
JPA's @AttributeOverride changes the column name, length or constraints of an embedded or inherited attribute, so one embeddable can be reused safely.
Complex types in JPA are value objects stored inside an entity. Learn @Embeddable, @ElementCollection and AttributeConverter with working examples.
@Convert applies a custom AttributeConverter to a JPA entity attribute. See how it differs from @Converter, how autoApply works and where it is not allowed.
Implement an AttributeConverter, annotate it with @Converter and map any Java type to a database column in JPA, with working enum and JSON examples.
The JPA @Converter annotation declares an AttributeConverter that maps a Java attribute type to a database column type and back. See autoApply, @Convert and practical examples.
Implement multi-tenancy with Hibernate 6: a CurrentTenantIdentifierResolver, a tenant filter, a schema connection provider and the TenantId discriminator.
JPA does not define @MultiTenant. Multi-tenancy comes from the provider: Hibernate @TenantId and resolvers, or EclipseLink @Multitenant.
Compare database-per-tenant, schema-per-tenant and @TenantId multi-tenancy in Hibernate 6, with Spring Boot code for the tenant resolver and connection provider.
The Spring Data JPA @Lock annotation selects the JPA lock mode for a repository query, enabling optimistic or pessimistic locking without EntityManager code.
Use JPA @Version to detect lost updates, test the conflict, return HTTP 409 and expose the version through ETag and If-Match headers.
@SequenceGenerator defines the database sequence JPA uses for primary keys. Learn its attributes, allocationSize and how it compares with IDENTITY.