mention @GeneratedColumn in the docs
This commit is contained in:
parent
4ce27e70ae
commit
5bcf691d2b
|
@ -909,6 +909,11 @@ The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibern
|
||||||
|
|
||||||
See the <<chapters/domain/basic_types.adoc#mapping-generated-Generated,`@Generated` mapping>> section for more info.
|
See the <<chapters/domain/basic_types.adoc#mapping-generated-Generated,`@Generated` mapping>> 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]]
|
[[annotations-hibernate-generatortype]]
|
||||||
==== `@GeneratorType`
|
==== `@GeneratorType`
|
||||||
|
|
||||||
|
|
|
@ -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]
|
[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]]
|
[[schema-generation-column-default-value-persist-example]]
|
||||||
.`@ColumnDefault` mapping 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]]
|
[[schema-generation-columns-unique-constraint]]
|
||||||
=== Columns unique constraint
|
=== Columns unique constraint
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue