diff --git a/documentation/src/main/asciidoc/userguide/appendices/Annotations.adoc b/documentation/src/main/asciidoc/userguide/appendices/Annotations.adoc index b51360947f..f3886a6bbe 100644 --- a/documentation/src/main/asciidoc/userguide/appendices/Annotations.adoc +++ b/documentation/src/main/asciidoc/userguide/appendices/Annotations.adoc @@ -909,6 +909,11 @@ The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibern See the <> section for more info. +[[annotations-hibernate-generatedcolumn]] +==== `@GeneratedColumn` + +The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/annotations/GeneratedColumn.html[`@GeneratedColumn`] annotation is used to specify that an entity attribute is generated by the database using `GENERATED ALWAYS AS` DDL. + [[annotations-hibernate-generatortype]] ==== `@GeneratorType` diff --git a/documentation/src/main/asciidoc/userguide/chapters/schema/Schema.adoc b/documentation/src/main/asciidoc/userguide/chapters/schema/Schema.adoc index bc7a7d898b..a089d3368d 100644 --- a/documentation/src/main/asciidoc/userguide/chapters/schema/Schema.adoc +++ b/documentation/src/main/asciidoc/userguide/chapters/schema/Schema.adoc @@ -136,14 +136,14 @@ include::{extrasdir}/schema-generation-column-default-value-mapping-example.sql[ ---- ==== -In the mapping above, both the `name` and `clientId` table columns are going to use a `DEFAULT` value. +In the mapping above, both the `name` and `clientId` table columns have a `DEFAULT` value. [NOTE] ==== -The `Person` entity above is annotated with the `@DynamicInsert` annotation so that the `INSERT` statement does not include any entity attribute that does not contain a value. +The `Person` entity above is annotated with the `@DynamicInsert` annotation so that the `INSERT` statement does not include any entity attribute which is null. ==== -This way, when omitting the `name` and the `clientId` attribute, the database is going to set them according to their default values. +This way, when the `name` and or `clientId` attribute is null, the database will set them according to their declared default values. [[schema-generation-column-default-value-persist-example]] .`@ColumnDefault` mapping example @@ -159,6 +159,11 @@ include::{extrasdir}/schema-generation-column-default-value-persist-example.sql[ ---- ==== +[TIP] +==== +If the column value should be generated not only when a row is inserted, but also when it's updated, the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/annotations/GeneratedColumn.html[`@GeneratedColumn`] annotation should be used. +==== + [[schema-generation-columns-unique-constraint]] === Columns unique constraint