org.castor.cpa.persistence.sql.keygen
Class HighLowKeyGeneratorFactory
java.lang.Object
org.castor.cpa.persistence.sql.keygen.HighLowKeyGeneratorFactory
- All Implemented Interfaces:
- KeyGeneratorFactory
public final class HighLowKeyGeneratorFactory
- extends java.lang.Object
- implements KeyGeneratorFactory
HIGH-LOW key generator factory. The short name of this key generator is "HIGH-LOW".
It uses the following alrorithm: a special sequence table must be in the database which keeps
the maximum key values. The name of the sequence table is a mandatory parameter of the key
generator, the parameter name is "table". The name of the primary key column of the sequence
table and the name of the column in which maximum values are stored are mandatory parameters
with the names "key-column" and "value-column", respectively. The key column contains table
names, so it must be of a character type (char or varchar). The value column contains primary
key values, it must be of a numeric type (numeric or int). Key generator reads the maximum
value X for the given table, writes the new value (X + N) to the sequence table and during
next N calls returns values X + 1, ..., X + N without database access. Number N called
"grab size" is an optional parameter of the key generator, its parameter name is "grab-size",
default value is "10". For example, if you want to obtain HIGH-LOW key generator with 3 digits
in the LOW part of the key, you should set "grab-size" to "1000".
- Version:
- $Revision: 8093 $ $Date: 2006-04-25 15:08:23 -0600 (Tue, 25 Apr 2006) $
- Author:
- Oleg Nitz, Ralf Joachim
- See Also:
HighLowKeyGenerator
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HighLowKeyGeneratorFactory
public HighLowKeyGeneratorFactory()
getKeyGeneratorName
public java.lang.String getKeyGeneratorName()
- Get the short name of the key generator. It is used to reference key generators in a
mapping configuration file. If several key generators of the same type are used for the
same database, then they are referenced by aliases.
- Specified by:
getKeyGeneratorName
in interface KeyGeneratorFactory
- Returns:
- Name of the
KeyGenerator
used to identify key generator (types).
getKeyGenerator
public KeyGenerator getKeyGenerator(PersistenceFactory factory,
java.util.Properties params,
int sqlType)
throws MappingException
- Produce the key generator.
- Specified by:
getKeyGenerator
in interface KeyGeneratorFactory
- Parameters:
factory
- Helper object for obtaining database-specific QuerySyntax.params
- Parameters for key generator.sqlType
- The SQL type of the primary key, the generated identities must have
the corresponding Java type, e.g. java.sql.Types.INTEGER corresponds to
java.lang.Integer, java.sql.Types.NUMERIC corresponds to java.lang.BigDecimal.
- Returns:
- A
KeyGenerator
instance.
- Throws:
MappingException
- If there's a problem resolving the mapping information.
Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com