* @param sqlType SQL type identifier.
* @return The {@link KeyGenerator} instance to be used.
*/
public KeyGenerator getKeyGenerator(final PersistenceFactory factory,
final KeyGeneratorDescriptor descriptor, final int sqlType) throws MappingException {
KeyGeneratorFactory keyGeneratorFactory;
String keyGeneratorName = descriptor.getName() + " " + sqlType;
// check whether there's already a valid KeyGenerator instance registered.
KeyGenerator keyGenerator = (KeyGenerator) _keyGenerators.get(keyGeneratorName);
if (keyGenerator == null) {
keyGeneratorFactory = KeyGeneratorFactoryRegistry.getKeyGeneratorFactory(
descriptor.getKeyGeneratorFactoryName());
if (keyGeneratorFactory != null) {
keyGenerator =
keyGeneratorFactory.getKeyGenerator(factory, descriptor.getParams(), sqlType);
if (keyGenerator != null) {
if (_log.isDebugEnabled()) {
_log.debug("Key generator " + descriptor.getKeyGeneratorFactoryName()
+ " has been instantiated, parameters: " + descriptor.getParams());
}