|
17 | 17 | * Allows specifying a pattern to be applied to the naming of columns for |
18 | 18 | * a particular {@linkplain jakarta.persistence.Embedded embedded mapping}. |
19 | 19 | * For example, given a typical embeddable named {@code Address} and |
20 | | - * {@code @Embedded @EmbeddedColumnNaming("home_%s)}, we will get columns named |
| 20 | + * {@code @EmbeddedColumnNaming("home_%s)}, we will get columns named |
21 | 21 | * {@code home_street}, {@code home_city}, etc. |
| 22 | + * <p/> |
| 23 | + * Explicit {@linkplain jakarta.persistence.Column @Column(name)} mappings are incorporated |
| 24 | + * into the result. When embeddables are nested, the affect will be cumulative. Given the following model: |
| 25 | + * |
| 26 | + * <pre> |
| 27 | + * @Entity |
| 28 | + * class Person { |
| 29 | + * ... |
| 30 | + * @Embedded |
| 31 | + * @EmbeddedColumnNaming("home_%s") |
| 32 | + * Address homeAddress; |
| 33 | + * @Embedded |
| 34 | + * @EmbeddedColumnNaming("work_%s") |
| 35 | + * Address workAddress; |
| 36 | + * } |
| 37 | + * |
| 38 | + * @Embeddable |
| 39 | + * class Address { |
| 40 | + * @Column(name="line1") |
| 41 | + * String street; |
| 42 | + * ... |
| 43 | + * @Embedded |
| 44 | + * @EmbeddedColumnNaming("zip_%s") |
| 45 | + * ZipPlus4 zip; |
| 46 | + * } |
| 47 | + * |
| 48 | + * @Embeddable |
| 49 | + * class ZipPlus4 { |
| 50 | + * @Column(name="zip_code") |
| 51 | + * String zipCode; |
| 52 | + * @Column(name="plus_code") |
| 53 | + * String plusCode; |
| 54 | + * } |
| 55 | + * </pre> |
| 56 | + * Will result in the following columns:<ol> |
| 57 | + * <li>{@code home_line1}</li> |
| 58 | + * <li>{@code home_zip_zip_code}</li> |
| 59 | + * <li>{@code home_zip_plus_code}</li> |
| 60 | + * <li>{@code work_line1}</li> |
| 61 | + * <li>{@code work_zip_zip_code}</li> |
| 62 | + * <li>{@code work_zip_plus_code}</li> |
| 63 | + * </ol> |
22 | 64 | * |
23 | 65 | * @since 7.0 |
24 | 66 | * @author Steve Ebersole |
|
33 | 75 | * <p/> |
34 | 76 | * The {@code value} may be omitted which will indicate to use the pattern |
35 | 77 | * {@code "{ATTRIBUTE_NAME}_%s"} where {@code {ATTRIBUTE_NAME}} is the name of the attribute |
36 | | - * where the annotation is placed. |
| 78 | + * where the annotation is placed - e.g. {@code @Embedded @EmbeddedColumnNaming Address homeAddress} |
| 79 | + * would create columns {@code homeAddress_street}, {@code homeAddress_city}, etc. |
37 | 80 | */ |
38 | 81 | String value() default ""; |
39 | 82 | } |
0 commit comments