All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.onetwo.dbm.id.CustomerIdGeneratorAdapter Maven / Gradle / Ivy

The newest version!
package org.onetwo.dbm.id;

import java.io.Serializable;
import java.util.List;

import org.onetwo.common.convert.Types;
import org.onetwo.dbm.core.spi.DbmSessionImplementor;

/**
 * @author wayshall
 * 
*/ public class CustomerIdGeneratorAdapter implements IdentifierGenerator{ final private String name; final private CustomIdGenerator customIdGenerator; final private Class valueType; public CustomerIdGeneratorAdapter(String name, CustomIdGenerator customIdGenerator, Class valueType) { super(); this.name = name; this.customIdGenerator = customIdGenerator; this.valueType = valueType; } @Override public StrategyType getStrategyType() { return StrategyType.DBM; } @Override public String getName() { return name; } @Override public Serializable generate(DbmSessionImplementor session) { T value = customIdGenerator.generate(session); if (valueType==Object.class) { return value; } return (Serializable)Types.convertValue(value, valueType); } @Override public List batchGenerate(DbmSessionImplementor session, int batchSize) { throw new UnsupportedOperationException("batch generate"); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy