站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

TableGenerator (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.id
Class TableGenerator

java.lang.Object
  extended bynet.sf.hibernate.id.TableGenerator
All Implemented Interfaces:
Configurable, IdentifierGenerator, PersistentIdentifierGenerator
Direct Known Subclasses:
TableHiLoGenerator

public class TableGenerator
extends Object
implements PersistentIdentifierGenerator, Configurable

An IdentifierGenerator that uses a database table to store the last generated value. It is not intended that applications use this strategy directly. However, it may be used to build other (efficient) strategies. The returned type is Integer.

The hi value MUST be fetched in a seperate transaction to the Session transaction so the generator must be able to obtain a new connection and commit it. Hence this implementation may not be used when Hibernate is fetching connections from an application server datasource or when the user is supplying connections.

The returned value is of type integer.

Mapping parameters supported: table, column

Author:
Gavin King
See Also:
TableHiLoGenerator

Field Summary
static String COLUMN
          The column parameter
static String TABLE
          The table parameter
 
Fields inherited from interface net.sf.hibernate.id.PersistentIdentifierGenerator
PK, SCHEMA
 
Constructor Summary
TableGenerator()
           
 
Method Summary
 void configure(Type type, Properties params, Dialect dialect)
          Configure this instance, given the value of parameters specified by the user as <param> elements.
 Serializable generate(SessionImplementor session, Object object)
          Generate a new identifier.
 Object generatorKey()
          Return a key unique to the underlying database objects.
 String[] sqlCreateStrings(Dialect dialect)
          The SQL required to create the underlying database objects.
 String sqlDropString(Dialect dialect)
          The SQL required to remove the underlying database objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLUMN

public static final String COLUMN
The column parameter

See Also:
Constant Field Values

TABLE

public static final String TABLE
The table parameter

See Also:
Constant Field Values
Constructor Detail

TableGenerator

public TableGenerator()
Method Detail

configure

public void configure(Type type,
                      Properties params,
                      Dialect dialect)
Description copied from interface: Configurable
Configure this instance, given the value of parameters specified by the user as <param> elements. This method is called just once, following instantiation.

Specified by:
configure in interface Configurable
Parameters:
params - param values, keyed by parameter name

generate

public Serializable generate(SessionImplementor session,
                             Object object)
                      throws SQLException,
                             HibernateException
Description copied from interface: IdentifierGenerator
Generate a new identifier.

Specified by:
generate in interface IdentifierGenerator
Parameters:
session -
object - the entity or toplevel collection for which the id is being generated
Returns:
Serializable a new identifier
Throws:
SQLException
HibernateException

sqlCreateStrings

public String[] sqlCreateStrings(Dialect dialect)
                          throws HibernateException
Description copied from interface: PersistentIdentifierGenerator
The SQL required to create the underlying database objects.

Specified by:
sqlCreateStrings in interface PersistentIdentifierGenerator
Parameters:
dialect -
Returns:
String[]
Throws:
HibernateException

sqlDropString

public String sqlDropString(Dialect dialect)
Description copied from interface: PersistentIdentifierGenerator
The SQL required to remove the underlying database objects.

Specified by:
sqlDropString in interface PersistentIdentifierGenerator
Parameters:
dialect -
Returns:
String

generatorKey

public Object generatorKey()
Description copied from interface: PersistentIdentifierGenerator
Return a key unique to the underlying database objects. Prevents us from trying to create/remove them multiple times.

Specified by:
generatorKey in interface PersistentIdentifierGenerator
Returns:
Object an identifying key for this generator