org.hibernate.id
Class IdentifierGeneratorHelper

java.lang.Object
  extended by org.hibernate.id.IdentifierGeneratorHelper

public final class IdentifierGeneratorHelper
extends java.lang.Object

Factory and helper methods for IdentifierGenerator framework.

Author:
Gavin King, Steve Ebersole

Nested Class Summary
static class IdentifierGeneratorHelper.BasicHolder
           
static class IdentifierGeneratorHelper.BigDecimalHolder
           
static class IdentifierGeneratorHelper.BigIntegerHolder
           
 
Field Summary
static java.io.Serializable POST_INSERT_INDICATOR
          Marker object returned from IdentifierGenerator.generate(org.hibernate.engine.SessionImplementor, java.lang.Object) to indicate that the entity's identifier will be generated as part of the datbase insertion.
static java.io.Serializable SHORT_CIRCUIT_INDICATOR
          Marker object returned from IdentifierGenerator.generate(org.hibernate.engine.SessionImplementor, java.lang.Object) to indicate that we should short-circuit any continued generated id checking.
 
Method Summary
static java.lang.Number createNumber(long value, java.lang.Class clazz)
          Deprecated. Use the holders instead.
static java.math.BigDecimal extractBigDecimal(IntegralDataTypeHolder holder)
           
static java.math.BigInteger extractBigInteger(IntegralDataTypeHolder holder)
           
static long extractLong(IntegralDataTypeHolder holder)
           
static java.io.Serializable get(java.sql.ResultSet rs, Type type)
          Extract the value from the result set (which is assumed to already have been positioned to the apopriate row) and wrp it in the appropriate Java numeric type.
static java.io.Serializable getGeneratedIdentity(java.sql.ResultSet rs, Type type)
          Get the generated identifier when using identity columns
static IntegralDataTypeHolder getIntegralDataTypeHolder(java.lang.Class integralType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHORT_CIRCUIT_INDICATOR

public static final java.io.Serializable SHORT_CIRCUIT_INDICATOR
Marker object returned from IdentifierGenerator.generate(org.hibernate.engine.SessionImplementor, java.lang.Object) to indicate that we should short-circuit any continued generated id checking. Currently this is only used in the case of the foreign generator as a way to signal that we should use the associated entity's id value.


POST_INSERT_INDICATOR

public static final java.io.Serializable POST_INSERT_INDICATOR
Marker object returned from IdentifierGenerator.generate(org.hibernate.engine.SessionImplementor, java.lang.Object) to indicate that the entity's identifier will be generated as part of the datbase insertion.

Method Detail

getGeneratedIdentity

public static java.io.Serializable getGeneratedIdentity(java.sql.ResultSet rs,
                                                        Type type)
                                                 throws java.sql.SQLException,
                                                        HibernateException
Get the generated identifier when using identity columns

Parameters:
rs - The result set from which to extract the the generated identity.
type - The expected type mapping for the identity value.
Returns:
The generated identity value
Throws:
java.sql.SQLException - Can be thrown while accessing the result set
HibernateException - Indicates a problem reading back a generated identity value.

get

public static java.io.Serializable get(java.sql.ResultSet rs,
                                       Type type)
                                throws java.sql.SQLException,
                                       IdentifierGenerationException
Extract the value from the result set (which is assumed to already have been positioned to the apopriate row) and wrp it in the appropriate Java numeric type.

Parameters:
rs - The result set from which to extract the value.
type - The expected type of the value.
Returns:
The extracted value.
Throws:
java.sql.SQLException - Indicates problems access the result set
IdentifierGenerationException - Indicates an unknown type.

createNumber

public static java.lang.Number createNumber(long value,
                                            java.lang.Class clazz)
                                     throws IdentifierGenerationException
Deprecated. Use the holders instead.

Wrap the given value in the given Java numeric class.

Parameters:
value - The primitive value to wrap.
clazz - The Java numeric type in which to wrap the value.
Returns:
The wrapped type.
Throws:
IdentifierGenerationException - Indicates an unhandled 'clazz'.

getIntegralDataTypeHolder

public static IntegralDataTypeHolder getIntegralDataTypeHolder(java.lang.Class integralType)

extractLong

public static long extractLong(IntegralDataTypeHolder holder)

extractBigInteger

public static java.math.BigInteger extractBigInteger(IntegralDataTypeHolder holder)

extractBigDecimal

public static java.math.BigDecimal extractBigDecimal(IntegralDataTypeHolder holder)


Copyright © 2010. All Rights Reserved.