Top Description Inners Fields Constructors Methods
org.hibernate.id

public Class SelectGenerator

extends AbstractPostInsertGenerator
Class Inheritance
Imports
java.io.Serializable, java.sql.PreparedStatement, .ResultSet, .SQLException, java.util.Properties, org.hibernate.HibernateException, .MappingException, org.hibernate.boot.model.relational.SqlStringGenerationContext, org.hibernate.dialect.Dialect, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.id.insert.AbstractSelectingDelegate, .IdentifierGeneratingInsert, .InsertGeneratedIdentifierDelegate, org.hibernate.service.ServiceRegistry, org.hibernate.type.Type

Deprecated

as a consequence of AbstractPostInsertGenerator being deprecated. See corresponding docs for further information.

A generator that selects the just inserted row to determine the identifier value assigned by the database. The correct row is located using a unique key.

One mapping parameter is required: key (unless a natural-id is defined in the mapping).

Author
Gavin King

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
SelectGenerator.SelectGeneratorDelegate

The delegate for the select generation strategy.

Field Summary

Modifier and TypeField and Description
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
configure(Type
The id property type descriptor
type
,
Properties
param values, keyed by parameter name
params
,
ServiceRegistry
Access to service that may be needed.
serviceRegistry
)

Overrides default org.hibernate.id.IdentifierGenerator.configure.

Configure this instance, given the value of parameters specified by the user as <param> elements.
private static String
public InsertGeneratedIdentifierDelegate
Inherited from org.hibernate.id.AbstractPostInsertGenerator:
determineBulkInsertionIdentifierGenerationSelectFragmentgeneratesupportsBulkInsertionIdentifierGeneration

Field Detail

uniqueKeyPropertyNameback to summary
private String uniqueKeyPropertyName

Constructor Detail

SelectGeneratorback to summary
public SelectGenerator()

Method Detail

configureback to summary
public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException

Overrides default org.hibernate.id.IdentifierGenerator.configure.

Doc from org.hibernate.id.IdentifierGenerator.configure.

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 registerExportables(Database).

Parameters
type:Type

The id property type descriptor

params:Properties

param values, keyed by parameter name

serviceRegistry:ServiceRegistry

Access to service that may be needed.

Annotations
@Override
Exceptions
MappingException:
If configuration fails.
determineNameOfPropertyToUseback to summary
private static String determineNameOfPropertyToUse(PostInsertIdentityPersister persister, String supplied)
getInsertGeneratedIdentifierDelegateback to summary
public InsertGeneratedIdentifierDelegate getInsertGeneratedIdentifierDelegate(PostInsertIdentityPersister persister, Dialect dialect, boolean isGetGeneratedKeysEnabled) throws HibernateException

Implements org.hibernate.id.PostInsertIdentifierGenerator.getInsertGeneratedIdentifierDelegate.

Annotations
@Override
org.hibernate.id back to summary

public Class SelectGenerator.SelectGeneratorDelegate

extends AbstractSelectingDelegate
implements InsertGeneratedIdentifierDelegate
Class Inheritance
All Implemented Interfaces
org.hibernate.id.insert.InsertGeneratedIdentifierDelegate

The delegate for the select generation strategy.

Field Summary

Modifier and TypeField and Description
private final Dialect
private final String
private final Type
private final PostInsertIdentityPersister
private final String
private final Type

Constructor Summary

AccessConstructor and Description
private
SelectGeneratorDelegate(PostInsertIdentityPersister persister, Dialect dialect, String suppliedUniqueKeyPropertyName)

Method Summary

Modifier and TypeMethod and Description
protected void
bindParameters(SharedSessionContractImplementor
The session
session
,
PreparedStatement
The prepared SQL command
ps
,
Object
The entity being saved.
entity
)

Overrides org.hibernate.id.insert.AbstractSelectingDelegate.bindParameters.

Bind any required parameter values into the SQL command getSelectSQL.
protected Serializable
getResult(SharedSessionContractImplementor
The session
session
,
ResultSet
The result set containing the generated primay key values.
rs
,
Object
The entity being saved.
entity
)

Implements abstract org.hibernate.id.insert.AbstractSelectingDelegate.getResult.

Extract the generated key value from the given result set.
protected String
getSelectSQL()

Implements abstract org.hibernate.id.insert.AbstractSelectingDelegate.getSelectSQL.

Get the SQL statement to be used to retrieve generated key values.
public IdentifierGeneratingInsert
prepareIdentifierGeneratingInsert(SqlStringGenerationContext
A context to help generate SQL strings
context
)

Overrides default org.hibernate.id.insert.InsertGeneratedIdentifierDelegate.prepareIdentifierGeneratingInsert.

Build a org.hibernate.sql.Insert specific to the delegate's mode of handling generated key values.
Inherited from org.hibernate.id.insert.AbstractSelectingDelegate:
performInsert

Field Detail

dialectback to summary
private final Dialect dialect
idSelectStringback to summary
private final String idSelectString
idTypeback to summary
private final Type idType
persisterback to summary
private final PostInsertIdentityPersister persister

Hides org.hibernate.id.insert.AbstractSelectingDelegate.persister.

uniqueKeyPropertyNameback to summary
private final String uniqueKeyPropertyName
uniqueKeyTypeback to summary
private final Type uniqueKeyType

Constructor Detail

SelectGeneratorDelegateback to summary
private SelectGeneratorDelegate(PostInsertIdentityPersister persister, Dialect dialect, String suppliedUniqueKeyPropertyName)

Method Detail

bindParametersback to summary
protected void bindParameters(SharedSessionContractImplementor session, PreparedStatement ps, Object entity) throws SQLException

Overrides org.hibernate.id.insert.AbstractSelectingDelegate.bindParameters.

Doc from org.hibernate.id.insert.AbstractSelectingDelegate.bindParameters.

Bind any required parameter values into the SQL command getSelectSQL.

Parameters
session:SharedSessionContractImplementor

The session

ps:PreparedStatement

The prepared SQL command

entity:Object

The entity being saved.

getResultback to summary
protected Serializable getResult(SharedSessionContractImplementor session, ResultSet rs, Object entity) throws SQLException

Implements abstract org.hibernate.id.insert.AbstractSelectingDelegate.getResult.

Doc from org.hibernate.id.insert.AbstractSelectingDelegate.getResult.

Extract the generated key value from the given result set.

Parameters
session:SharedSessionContractImplementor

The session

rs:ResultSet

The result set containing the generated primay key values.

entity:Object

The entity being saved.

Returns:Serializable

The generated identifier

getSelectSQLback to summary
protected String getSelectSQL()

Implements abstract org.hibernate.id.insert.AbstractSelectingDelegate.getSelectSQL.

Doc from org.hibernate.id.insert.AbstractSelectingDelegate.getSelectSQL.

Get the SQL statement to be used to retrieve generated key values.

Returns:String

The SQL command string

prepareIdentifierGeneratingInsertback to summary
public IdentifierGeneratingInsert prepareIdentifierGeneratingInsert(SqlStringGenerationContext context)

Overrides default org.hibernate.id.insert.InsertGeneratedIdentifierDelegate.prepareIdentifierGeneratingInsert.

Doc from org.hibernate.id.insert.InsertGeneratedIdentifierDelegate.prepareIdentifierGeneratingInsert.

Build a org.hibernate.sql.Insert specific to the delegate's mode of handling generated key values.

Parameters
context:SqlStringGenerationContext

A context to help generate SQL strings

Returns:IdentifierGeneratingInsert

The insert object.

Annotations
@Override