Package org.hibernate.annotations
Annotation Interface EmbeddedColumnNaming
Allows specifying a pattern to be applied to the naming of columns for
a particular embedded mapping.
For example, given a typical embeddable named
Address and
@EmbeddedColumnNaming("home_%s), we will get columns named
home_street, home_city, etc.
Explicit @Column(name) mappings are incorporated
into the result. When embeddables are nested, the affect will be cumulative. Given the following model:
@Entity
class Person {
...
@Embedded
@EmbeddedColumnNaming("home_%s")
Address homeAddress;
@Embedded
@EmbeddedColumnNaming("work_%s")
Address workAddress;
}
@Embeddable
class Address {
@Column(name="line1")
String street;
...
@Embedded
@EmbeddedColumnNaming("zip_%s")
ZipPlus4 zip;
}
@Embeddable
class ZipPlus4 {
@Column(name="zip_code")
String zipCode;
@Column(name="plus_code")
String plusCode;
}
Will result in the following columns:home_line1home_zip_zip_codehome_zip_plus_codework_line1work_zip_zip_codework_zip_plus_code
- Since:
- 7.0
-
Optional Element Summary
Optional Elements
-
Element Details
-
value
String valueThe naming pattern. It is expected to contain a single pattern marker (%) into which the "raw" column name will be injected. Thevaluemay be omitted which will indicate to use the pattern"{ATTRIBUTE_NAME}_%s"where{ATTRIBUTE_NAME}is the name of the attribute where the annotation is placed - e.g.@Embedded @EmbeddedColumnNaming Address homeAddresswould create columnshomeAddress_street,homeAddress_city, etc.- Default:
""
-