Annotation Interface EmbeddedColumnNaming


@Target({METHOD,FIELD}) @Retention(RUNTIME) @Incubating public @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:
  1. home_line1
  2. home_zip_zip_code
  3. home_zip_plus_code
  4. work_line1
  5. work_zip_zip_code
  6. work_zip_plus_code
Since:
7.0
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The naming pattern.
  • Element Details

    • value

      String value
      The naming pattern. It is expected to contain a single pattern marker (%) into which the "raw" column name will be injected.

      The value may 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 homeAddress would create columns homeAddress_street, homeAddress_city, etc.

      Default:
      ""