本文整理汇总了Java中org.hibernate.id.Configurable类的典型用法代码示例。如果您正苦于以下问题:Java Configurable类的具体用法?Java Configurable怎么用?Java Configurable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Configurable类属于org.hibernate.id包,在下文中一共展示了Configurable类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.hibernate.id.Configurable; //导入依赖的package包/类
/**
* The main method.
*
* @param args
* the arguments
* @throws Exception
* the exception
*/
public static void main(String[] args) throws Exception {
Properties props = new Properties();
props.setProperty("separator", "");
IdentifierGenerator gen = new UIDGenerator();
((Configurable) gen).configure(Hibernate.STRING, props, null);
IdentifierGenerator gen2 = new UIDGenerator();
((Configurable) gen2).configure(Hibernate.STRING, props, null);
for (int i = 0; i < 10; i++) {
String id = (String) gen.generate(null, gen);
System.out.println(id);
String id2 = (String) gen2.generate(null, gen2);
System.out.println(id2);
}
}
示例2: createIdentifierGenerator
import org.hibernate.id.Configurable; //导入依赖的package包/类
public IdentifierGenerator createIdentifierGenerator(String strategy, Type type, Properties config) {
try {
Class clazz = getIdentifierGeneratorClass( strategy );
CustomGenerator identifierGenerator = ( CustomGenerator ) clazz.newInstance();
if ( identifierGenerator instanceof Configurable ) {
( ( Configurable ) identifierGenerator ).configure( type, config, dialect );
}
return identifierGenerator;
}
catch ( Exception e ) {
final String entityName = config.getProperty( IdentifierGenerator.ENTITY_NAME );
throw new MappingException( String.format( "Could not instantiate id generator [entity-name=%s]", entityName ), e );
}
}
示例3: createIdentifierGenerator
import org.hibernate.id.Configurable; //导入依赖的package包/类
@Override
public IdentifierGenerator createIdentifierGenerator(String strategy, Type type, Properties config) {
try {
Class clazz = getIdentifierGeneratorClass( strategy );
IdentifierGenerator identifierGenerator = ( IdentifierGenerator ) clazz.newInstance();
if ( identifierGenerator instanceof Configurable ) {
( ( Configurable ) identifierGenerator ).configure( type, config, dialect );
}
return identifierGenerator;
}
catch ( Exception e ) {
final String entityName = config.getProperty( IdentifierGenerator.ENTITY_NAME );
throw new MappingException( String.format( "Could not instantiate id generator [entity-name=%s]", entityName ), e );
}
}
示例4: generateUniqueContentFolderID
import org.hibernate.id.Configurable; //导入依赖的package包/类
public static String generateUniqueContentFolderID() {
IdentifierGenerator uuidGen = new UUIDGenerator();
((Configurable) uuidGen).configure(StringType.INSTANCE, new Properties(), null);
// lowercase to resolve OS issues
return ((String) uuidGen.generate(null, null)).toLowerCase();
}
示例5: generateUniqueKey
import org.hibernate.id.Configurable; //导入依赖的package包/类
/**
* Generates the unique key used for the forgot password request
*
* @return a unique key
* @throws FileUtilException
* @throws IOException
*/
public static String generateUniqueKey() {
Properties props = new Properties();
IdentifierGenerator uuidGen = new UUIDGenerator();
((Configurable) uuidGen).configure(StringType.INSTANCE, props, null);
return ((String) uuidGen.generate(null, null)).toLowerCase();
}
示例6: configure
import org.hibernate.id.Configurable; //导入依赖的package包/类
public void configure(Type type, Properties params, Dialect d) throws MappingException {
if (getGenerator() instanceof Configurable) {
if (params.getProperty("schema") == null && sDefaultSchema != null)
params.setProperty("schema", sDefaultSchema);
if (params.get("identifier_normalizer") == null && sNormalizer != null)
params.put("identifier_normalizer", sNormalizer);
((Configurable)getGenerator()).configure(type, params, d);
}
}