Package org.hibernate.tuple
Class TenantIdGeneration
- java.lang.Object
-
- org.hibernate.tuple.TenantIdGeneration
-
- All Implemented Interfaces:
Serializable,AnnotationValueGeneration<TenantId>,ValueGeneration,ValueGenerator<Object>
public class TenantIdGeneration extends Object implements AnnotationValueGeneration<TenantId>, ValueGenerator<Object>
Value generation implementation forTenantId.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TenantIdGeneration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectgenerateValue(Session session, Object owner)Generate the value.ObjectgenerateValue(Session session, Object owner, Object currentValue)Generate the value.StringgetDatabaseGeneratedReferencedColumnValue()For values which are generated in the database (ValueGeneration.getValueGenerator()==null), if the column will be referenced in the SQL (ValueGeneration.referenceColumnInSql()==true), what value should be used in the SQL as the column value.GenerationTiminggetGenerationTiming()When is this value generated : NEVER, INSERT, ALWAYS (INSERT+UPDATE)ValueGenerator<?>getValueGenerator()Obtain the in-VM value generator.voidinitialize(TenantId annotation, Class<?> propertyType)Initializes this generation strategy for the given annotation instance.voidinitialize(TenantId annotation, Class<?> propertyType, String entityName, String propertyName)Initializes this generation strategy for the given annotation instance.booleanreferenceColumnInSql()For values which are generated in the database (ValueGeneration.getValueGenerator()==null), should the column be referenced in the INSERT / UPDATE SQL?-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.tuple.ValueGeneration
timingMatches
-
-
-
-
Method Detail
-
initialize
public void initialize(TenantId annotation, Class<?> propertyType, String entityName, String propertyName)
Description copied from interface:AnnotationValueGenerationInitializes this generation strategy for the given annotation instance.- Specified by:
initializein interfaceAnnotationValueGeneration<TenantId>- Parameters:
annotation- an instance of the strategy's annotation type. Typically implementations will retrieve the annotation's attribute values and store them in fields.propertyType- the type of the property annotated with the generator annotation. Implementations may use the type to determine the rightValueGeneratorto be applied.entityName- the name of the entity to which the annotated property belongspropertyName- the name of the annotated property
-
initialize
public void initialize(TenantId annotation, Class<?> propertyType)
Description copied from interface:AnnotationValueGenerationInitializes this generation strategy for the given annotation instance.- Specified by:
initializein interfaceAnnotationValueGeneration<TenantId>- Parameters:
annotation- an instance of the strategy's annotation type. Typically implementations will retrieve the annotation's attribute values and store them in fields.propertyType- the type of the property annotated with the generator annotation. Implementations may use the type to determine the rightValueGeneratorto be applied.
-
getGenerationTiming
public GenerationTiming getGenerationTiming()
Description copied from interface:ValueGenerationWhen is this value generated : NEVER, INSERT, ALWAYS (INSERT+UPDATE)- Specified by:
getGenerationTimingin interfaceValueGeneration- Returns:
- When the value is generated.
-
getValueGenerator
public ValueGenerator<?> getValueGenerator()
Description copied from interface:ValueGenerationObtain the in-VM value generator. May returnnull. In fact for values that are generated "in the database" via execution of the INSERT/UPDATE statement, the expectation is thatnullbe returned here- Specified by:
getValueGeneratorin interfaceValueGeneration- Returns:
- The strategy for performing in-VM value generation
-
generateValue
public Object generateValue(Session session, Object owner, Object currentValue)
Description copied from interface:ValueGeneratorGenerate the value.- Specified by:
generateValuein interfaceValueGenerator<Object>- Parameters:
session- The Session from which the request originates.owner- The instance of the object owning the attribute for which we are generating a value.currentValue- The current value assigned to the property- Returns:
- The generated value
-
generateValue
public Object generateValue(Session session, Object owner)
Description copied from interface:ValueGeneratorGenerate the value.- Specified by:
generateValuein interfaceValueGenerator<Object>- Parameters:
session- The Session from which the request originates.owner- The instance of the object owning the attribute for which we are generating a value.- Returns:
- The generated value
-
referenceColumnInSql
public boolean referenceColumnInSql()
Description copied from interface:ValueGenerationFor values which are generated in the database (ValueGeneration.getValueGenerator()==null), should the column be referenced in the INSERT / UPDATE SQL? This will be false most often to have a DDL-defined DEFAULT value be applied on INSERT- Specified by:
referenceColumnInSqlin interfaceValueGeneration- Returns:
trueindicates the column should be included in the SQL.
-
getDatabaseGeneratedReferencedColumnValue
public String getDatabaseGeneratedReferencedColumnValue()
Description copied from interface:ValueGenerationFor values which are generated in the database (ValueGeneration.getValueGenerator()==null), if the column will be referenced in the SQL (ValueGeneration.referenceColumnInSql()==true), what value should be used in the SQL as the column value. Generally this will be a function call or a marker (DEFAULTS). NOTE : for in-VM generation, this will not be called and the column value will implicitly be a JDBC parameter ('?')- Specified by:
getDatabaseGeneratedReferencedColumnValuein interfaceValueGeneration- Returns:
- The column value to be used in the SQL.
-
-