Skip to content

Commit 3e7c40e

Browse files
committed
add an example of @generated @ColumnDefault to the javadoc
1 parent 2cd4403 commit 3e7c40e

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

hibernate-core/src/main/java/org/hibernate/annotations/ColumnDefault.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@
2222
* the defaulted value of a database column.
2323
* </ul>
2424
* <p>
25+
* For example, this field will be populated with the value {@code "new"} by
26+
* the database when the entity is inserted:
27+
* <pre>
28+
* &#064;Generated &#064;ColumnDefault(value = "'new'")
29+
* private String status;
30+
* </pre>
31+
* <p>
2532
* If {@code @Generated} is not used, a {@code default} value can cause state
2633
* held in memory to lose synchronization with the database.
2734
*
2835
* @author Steve Ebersole
2936
*
37+
* @see Generated
3038
* @see GeneratedColumn
3139
* @see DialectOverride.ColumnDefault
3240
*/

hibernate-core/src/main/java/org/hibernate/annotations/Formula.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@
4545
* a formula may involve columns of the primary table, or columns of any one of the
4646
* secondary tables. But it may not involve columns of more than one table.
4747
* <p>
48-
* The {@link ColumnTransformer} annotation is an alternative in certain cases, allowing
49-
* the use of native SQL to read <em>and write</em> values to a column.
48+
* The {@link ColumnTransformer @ColumnTransformer} annotation is an alternative in
49+
* certain cases, allowing the use of native SQL to read <em>and write</em> values to
50+
* a column.
5051
* <pre>
5152
* // it might be better to use &#64;ColumnTransformer in this case
5253
* &#064;Formula("decrypt(credit_card_num)")
5354
* String getCreditCardNumber() { ... }
5455
* </pre>
5556
*
57+
* @see Generated
5658
* @see ColumnTransformer
5759
* @see DiscriminatorFormula
5860
* @see JoinFormula

hibernate-core/src/main/java/org/hibernate/annotations/Generated.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@
4242
* <ul>
4343
* <li>a database table has a column value populated by a database trigger,
4444
* <li>a mapped column has a default value defined in DDL, in which case
45-
* {@code @Generated} is used in conjunction with {@link ColumnDefault},
45+
* {@code @Generated} is used in conjunction with the
46+
* {@link ColumnDefault @ColumnDefault} annotation,
4647
* <li>a {@linkplain #sql() SQL expression} is used to compute the value of
4748
* a mapped column,
4849
* <li>a custom SQL {@link SQLInsert insert} or {@link SQLUpdate update}
4950
* statement specified by an entity assigns a value to the annotated
5051
* property of the entity, or {@linkplain #writable transforms} the
5152
* value currently assigned to the annotated property, or
5253
* <li>there is no mapped column, and the value of the field is determined
53-
* by evaluating a SQL {@link Formula}.
54+
* by evaluating a SQL {@link Formula @Formula}.
5455
* </ul>
5556
* <p>
5657
* On the other hand:

0 commit comments

Comments
 (0)