org.exolab.castor.jdo.keygen
Class MaxKeyGeneratorFactory
java.lang.Object
org.exolab.castor.jdo.keygen.MaxKeyGeneratorFactory
- All Implemented Interfaces:
- KeyGeneratorFactory
- public final class MaxKeyGeneratorFactory
- extends java.lang.Object
- implements KeyGeneratorFactory
MAX key generator factory.
The short name of this key generator is "MAX".
It uses the following alrorithm: the maximum value of the primary
key is fetched and the correspondent record is locked until the end
of transaction, generator returns (max + 1).
The lock guarantees that key generators of concurrent transactions
will not use this key value, so DuplicateKeyException is impossible.
If the table is empty, generator returns 1, no lock is put,
DuplicateKeyException is possible.
- Version:
- $Revision: 7121 $ $Date: 2005-06-01 06:08:22 -0600 (Wed, 01 Jun 2005) $
- Author:
- Oleg Nitz
- See Also:
MaxKeyGenerator
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MaxKeyGeneratorFactory
public MaxKeyGeneratorFactory()
getKeyGenerator
public KeyGenerator getKeyGenerator(PersistenceFactory factory,
java.util.Properties params,
int sqlType)
throws org.exolab.castor.mapping.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:
org.exolab.castor.mapping.MappingException
getName
public java.lang.String getName()
- The short name of this key generator is "MAX".
- Specified by:
getName in interface KeyGeneratorFactory
Copyright 2008 null. All Rights Reserved.