5.6. Generated properties

Generated properties are properties that have their values generated by the database. Typically, Hibernate applications needed to refresh objects that contain any properties for which the database was generating values. Marking properties as generated, however, lets the application delegate this responsibility to Hibernate. When Hibernate issues an SQL INSERT or UPDATE for an entity that has defined generated properties, it immediately issues a select afterwards to retrieve the generated values.
Properties marked as generated must additionally be non-insertable and non-updateable. Only Section 5.1.9, “Version (optional)”, Section 5.1.10, “Timestamp (optional)”, and Section 5.1.11, “Property”, can be marked as generated.
never (the default): the given property value is not generated within the database.
insert: the given property value is generated on insert, but is not regenerated on subsequent updates. Properties like created-date fall into this category. Even though Section 5.1.9, “Version (optional)” and Section 5.1.10, “Timestamp (optional)” properties can be marked as generated, this option is not available.
always: the property value is generated both on insert and on update.