diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Formula.java b/hibernate-core/src/main/java/org/hibernate/annotations/Formula.java index c8cc6e9963b0..3ee1ab2eb9f2 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/Formula.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/Formula.java @@ -32,6 +32,15 @@ * Character middleInitial; * *
+ * 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: + *
+ * @Generated // evaluate the formula after an insert + * @Formula("sub_total * (1.0 + tax)") + * BigDecimal totalWithTax; + *+ *
* 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 * secondary tables. But it may not involve columns of more than one table. diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Generated.java b/hibernate-core/src/main/java/org/hibernate/annotations/Generated.java index 2dd3d61f88dc..71b24a4de995 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/Generated.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/Generated.java @@ -31,11 +31,13 @@ *
* On the other hand: