Package org.hibernate.annotations
Annotation Type Generated
-
@Target({FIELD,METHOD}) @Retention(RUNTIME) public @interface Generated
Specifies that the value of the annotated property is generated by the database. The generated value will be automatically retrieved using a SQLSELECTafter it is generated.Generatedrelieves the program of the need to callSession.refresh(Object)explicitly to synchronize state held in memory with state generated by the database when a SQLINSERTorUPDATEis executed.This is most useful for working with database tables where a column value is populated by a database trigger. A second possible scenario is the use of
Generated(INSERT)withColumnDefault.- For identity/autoincrement columns mapped to an identifier property,
use
GeneratedValue. - For columns with a
generated always asclause, prefer theGeneratedColumnannotation.
- See Also:
GeneratedValue,ColumnDefault,GeneratedColumn
- For identity/autoincrement columns mapped to an identifier property,
use
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description GenerationTimevalueSpecifies the events that cause the value to be generated by the database.
-
-
-
Element Detail
-
value
GenerationTime value
Specifies the events that cause the value to be generated by the database.- If
GenerationTime.INSERT, the generated value will be selected after each SQLINSERTstatement is executed. - If
GenerationTime.ALWAYS, the generated value will be selected after each SQLINSERTorUPDATEstatement is executed.
- If
-
-