Class Assigned

java.lang.Object
org.hibernate.id.Assigned
All Implemented Interfaces:
Serializable, ExportableProducer, BeforeExecutionGenerator, Generator, Configurable, StandardGenerator, IdentifierGenerator

public class Assigned extends Object implements IdentifierGenerator, StandardGenerator
An IdentifierGenerator that returns the current identifier assigned to an instance.
Author:
Gavin King
See Also:
  • Constructor Details

    • Assigned

      public Assigned()
  • Method Details

    • generate

      public Object generate(SharedSessionContractImplementor session, Object obj) throws HibernateException
      Description copied from interface: IdentifierGenerator
      Generate a new identifier.
      Specified by:
      generate in interface IdentifierGenerator
      Parameters:
      session - The session from which the request originates
      obj - the entity or collection (idbag) for which the id is being generated
      Returns:
      a new identifier
      Throws:
      HibernateException - Indicates trouble generating the identifier
    • configure

      public void configure(Type type, Properties parameters, ServiceRegistry serviceRegistry) throws MappingException
      Description copied from interface: IdentifierGenerator
      Configure this instance, given the value of parameters specified by the user as <param> elements.

      This method is called just once, following instantiation, and before IdentifierGenerator.registerExportables(Database).

      Specified by:
      configure in interface Configurable
      Specified by:
      configure in interface IdentifierGenerator
      Parameters:
      type - The id property type descriptor
      parameters - param values, keyed by parameter name
      serviceRegistry - Access to service that may be needed.
      Throws:
      MappingException - If configuration fails.
    • 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 interface Generator
      Returns:
      true if this generator allows pre-assigned identifier values, false otherwise (default).