Value objects stay in the same row while giving the model a proper type.
@Embeddable
record Address(String line1, String city, String postcode) { }
@Entity
class Customer {
@Id Long id;
@Embedded Address home;
@Embedded
@AttributeOverride(name = "city", column = @Column(name = "billing_city"))
Address billing;
}
One table: customers(id, line1, city, postcode, line1, billing_city, postcode)
AttributeOverride is required whenever the same embeddable appears twice.
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-08-11