Package org.hibernate.generator
Class Assigned
java.lang.Object
org.hibernate.generator.Assigned
- All Implemented Interfaces:
Serializable
,Generator
- Direct Known Subclasses:
Assigned
A
Generator
that doesn't generate.
Identifier fields with an Assigned
generator
must be assigned a value by the application program.
This replaces the Assigned
identifier generation strategy from older versions
of Hibernate.
- Since:
- 7.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determine if this generator allows identifier values to be manually assigned to the entity instance before persisting it.boolean
Determine if this generator allows generated fields to be manually assigned a value on events which do not trigger value generation.boolean
generatedBeforeExecution
(Object entity, SharedSessionContractImplementor session) Determines if the property value is generated before in Java code that executes before the row is written.boolean
Determines if the property value is generated when a row is written to the database, or in Java code that executes before the row is written.boolean
generatedOnExecution
(Object entity, SharedSessionContractImplementor session) Determines if the property value is generated when a row is written to the database.boolean
boolean
boolean
The event types for which this generator should be called to produce a new value.
-
Constructor Details
-
Assigned
public Assigned()
-
-
Method Details
-
generatedOnExecution
public boolean generatedOnExecution()Description copied from interface:Generator
Determines if the property value is generated when a row is written to the database, or in Java code that executes before the row is written.- Generators which only implement
BeforeExecutionGenerator
must resultfalse
. - Generators which only implement
OnExecutionGenerator
must resulttrue
. - Generators which implement both subinterfaces may decide at runtime what value to return.
- Specified by:
generatedOnExecution
in interfaceGenerator
- Returns:
true
if the value is generated by the database as a side effect of the execution of aninsert
orupdate
statement, or false if it is generated in Java code before the statement is executed via JDBC.
- Generators which only implement
-
allowAssignedIdentifiers
public boolean allowAssignedIdentifiers()Description copied from interface:Generator
Determine if this generator allows identifier values to be manually assigned to the entity instance before persisting it. This is useful when, for example, needing existing assigned values to be used as identifiers and falling back to generated values by default.- Specified by:
allowAssignedIdentifiers
in interfaceGenerator
- Returns:
true
if this generator allows pre-assigned identifier values,false
otherwise (default).
-
allowMutation
public boolean allowMutation()Description copied from interface:Generator
Determine if this generator allows generated fields to be manually assigned a value on events which do not trigger value generation.- Specified by:
allowMutation
in interfaceGenerator
- Returns:
true
if this generator allows manually assigned values,false
otherwise (default).
-
getEventTypes
Description copied from interface:Generator
The event types for which this generator should be called to produce a new value.Identifier generators must return
EventTypeSets.INSERT_ONLY
.- Specified by:
getEventTypes
in interfaceGenerator
- Returns:
- a set of
EventType
s.
-
generatesSometimes
public boolean generatesSometimes()- Specified by:
generatesSometimes
in interfaceGenerator
-
generatesOnInsert
public boolean generatesOnInsert()- Specified by:
generatesOnInsert
in interfaceGenerator
-
generatesOnUpdate
public boolean generatesOnUpdate()- Specified by:
generatesOnUpdate
in interfaceGenerator
-