HHH-18809 update Javadoc with this usage

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-11-04 22:10:21 +01:00
parent e4b52c2cf1
commit 7fec477bc2
2 changed files with 15 additions and 4 deletions

View File

@ -32,6 +32,15 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
* Character middleInitial; * Character middleInitial;
* </pre> * </pre>
* <p> * <p>
* By default, the fields of an entity are not updated with the results of evaluating
* the formula after an {@code insert} or {@code update}. The {@link Generated @Generated}
* annotation may be used to specify that this should happen:
* <pre>
* &#64;Generated // evaluate the formula after an insert
* &#64;Formula("sub_total * (1.0 + tax)")
* BigDecimal totalWithTax;
* </pre>
* <p>
* For an entity with {@linkplain jakarta.persistence.SecondaryTable secondary tables}, * For an entity with {@linkplain jakarta.persistence.SecondaryTable secondary tables},
* a formula may involve columns of the primary table, or columns of any one of the * a formula may involve columns of the primary table, or columns of any one of the
* secondary tables. But it may not involve columns of more than one table. * secondary tables. But it may not involve columns of more than one table.

View File

@ -31,11 +31,13 @@ import static org.hibernate.generator.EventType.INSERT;
* <li>a mapped column has a default value defined in DDL, in which case * <li>a mapped column has a default value defined in DDL, in which case
* {@code @Generated} is used in conjunction with {@link ColumnDefault}, * {@code @Generated} is used in conjunction with {@link ColumnDefault},
* <li>a {@linkplain #sql() SQL expression} is used to compute the value of * <li>a {@linkplain #sql() SQL expression} is used to compute the value of
* a mapped column, or * a mapped column,
* <li>when a custom SQL {@link SQLInsert insert} or {@link SQLUpdate update} * <li>a custom SQL {@link SQLInsert insert} or {@link SQLUpdate update}
* statement specified by an entity assigns a value to the annotated * statement specified by an entity assigns a value to the annotated
* property of the entity, or {@linkplain #writable() transforms} the * property of the entity, or {@linkplain #writable transforms} the
* value currently assigned to the annotated property. * value currently assigned to the annotated property, or
* <li>there is no mapped column, and the value of the field is determined
* by evaluating a SQL {@link Formula}.
* </ul> * </ul>
* <p> * <p>
* On the other hand: * On the other hand: