org.exolab.castor.jdo.keygen
Class HighLowKeyGeneratorFactory

java.lang.Object
  extended by org.exolab.castor.jdo.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 with 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 (which sometimes is called "grab size") is an optional parameter of the key generator, the parameter name is "grab-size", default value is "1". 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: 1.1 $ $Date: 2005/06/01 12:08:16 $
Author:
Oleg Nitz
See Also:
HighLowKeyGenerator

Constructor Summary
HighLowKeyGeneratorFactory()
           
 
Method Summary
 KeyGenerator getKeyGenerator(PersistenceFactory factory, java.util.Properties params, int sqlType)
          Produce the key generator.
 java.lang.String getName()
          The short name of this key generator is "HIGH-LOW"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HighLowKeyGeneratorFactory

public HighLowKeyGeneratorFactory()
Method Detail

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.
Throws:
MappingException
Factory:
Helper object for obtaining database-specific QuerySyntax.

getName

public java.lang.String getName()
The short name of this key generator is "HIGH-LOW"

Specified by:
getName in interface KeyGeneratorFactory


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com