org.hibernate.id.insert
Class AbstractSelectingDelegate

java.lang.Object
  extended by org.hibernate.id.insert.AbstractSelectingDelegate
All Implemented Interfaces:
InsertGeneratedIdentifierDelegate
Direct Known Subclasses:
IdentityGenerator.BasicDelegate, SelectGenerator.SelectGeneratorDelegate

public abstract class AbstractSelectingDelegate
extends Object
implements InsertGeneratedIdentifierDelegate

Abstract InsertGeneratedIdentifierDelegate implementation where the underlying strategy requires an subsequent select after the insert to determine the generated identifier.


Constructor Summary
protected AbstractSelectingDelegate(PostInsertIdentityPersister persister)
           
 
Method Summary
protected  void bindParameters(SessionImplementor session, PreparedStatement ps, Object entity)
          Bind any required parameter values into the SQL command getSelectSQL().
protected abstract  Serializable getResult(SessionImplementor session, ResultSet rs, Object entity)
          Extract the generated key value from the given result set.
protected abstract  String getSelectSQL()
          Get the SQL statement to be used to retrieve generated key values.
 Serializable performInsert(String insertSQL, SessionImplementor session, Binder binder)
          Perform the indicated insert SQL statement and determine the identifier value generated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.hibernate.id.insert.InsertGeneratedIdentifierDelegate
prepareIdentifierGeneratingInsert
 

Constructor Detail

AbstractSelectingDelegate

protected AbstractSelectingDelegate(PostInsertIdentityPersister persister)
Method Detail

performInsert

public final Serializable performInsert(String insertSQL,
                                        SessionImplementor session,
                                        Binder binder)
Description copied from interface: InsertGeneratedIdentifierDelegate
Perform the indicated insert SQL statement and determine the identifier value generated.

Specified by:
performInsert in interface InsertGeneratedIdentifierDelegate
Parameters:
insertSQL - The INSERT statement string
session - The session in which we are operating
binder - The param binder
Returns:
The generated identifier value.

getSelectSQL

protected abstract String getSelectSQL()
Get the SQL statement to be used to retrieve generated key values.

Returns:
The SQL command string

bindParameters

protected void bindParameters(SessionImplementor session,
                              PreparedStatement ps,
                              Object entity)
                       throws SQLException
Bind any required parameter values into the SQL command getSelectSQL().

Parameters:
session - The session
ps - The prepared SQL command
entity - The entity being saved.
Throws:
SQLException

getResult

protected abstract Serializable getResult(SessionImplementor session,
                                          ResultSet rs,
                                          Object entity)
                                   throws SQLException
Extract the generated key value from the given result set.

Parameters:
session - The session
rs - The result set containing the generated primay key values.
entity - The entity being saved.
Returns:
The generated identifier
Throws:
SQLException


Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.