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 SQLSELECT
after it is generated.Generated
relieves the program of the need to callSession.refresh(Object)
explicitly to synchronize state held in memory with state generated by the database when a SQLINSERT
orUPDATE
is 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 as
clause, prefer theGeneratedColumn
annotation.
- 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 GenerationTime
value
Specifies 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 SQLINSERT
statement is executed. - If
GenerationTime.ALWAYS
, the generated value will be selected after each SQLINSERT
orUPDATE
statement is executed.
- If
-
-