当前位置: 首页>>代码示例>>Java>>正文


Java IdentifierGenerator类代码示例

本文整理汇总了Java中org.hibernate.id.IdentifierGenerator的典型用法代码示例。如果您正苦于以下问题:Java IdentifierGenerator类的具体用法?Java IdentifierGenerator怎么用?Java IdentifierGenerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IdentifierGenerator类属于org.hibernate.id包,在下文中一共展示了IdentifierGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createIdentifierGenerator

import org.hibernate.id.IdentifierGenerator; //导入依赖的package包/类
@Override
public IdentifierGenerator createIdentifierGenerator(
		IdentifierGeneratorFactory identifierGeneratorFactory,
		Dialect dialect,
		String defaultCatalog,
		String defaultSchema,
		RootClass rootClass) throws MappingException {
	if ( builtIdentifierGenerator == null ) {
		builtIdentifierGenerator = buildIdentifierGenerator(
				identifierGeneratorFactory,
				dialect,
				defaultCatalog,
				defaultSchema,
				rootClass
		);
	}
	return builtIdentifierGenerator;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:Component.java

示例2: IdentifierProperty

import org.hibernate.id.IdentifierGenerator; //导入依赖的package包/类
/**
 * Construct a non-virtual identifier property.
 *
 * @param name The name of the property representing the identifier within
 * its owning entity.
 * @param node The node name to use for XML-based representation of this
 * property.
 * @param type The Hibernate Type for the identifier property.
 * @param embedded Is this an embedded identifier.
 * @param unsavedValue The value which, if found as the value on the identifier
 * property, represents new (i.e., un-saved) instances of the owning entity.
 * @param identifierGenerator The generator to use for id value generation.
 */
public IdentifierProperty(
		String name,
		String node,
		Type type,
		boolean embedded,
		IdentifierValue unsavedValue,
		IdentifierGenerator identifierGenerator) {
	super( name, type );
	this.virtual = false;
	this.embedded = embedded;
	this.hasIdentifierMapper = false;
	this.unsavedValue = unsavedValue;
	this.identifierGenerator = identifierGenerator;
	this.identifierAssignedByInsert = identifierGenerator instanceof PostInsertIdentifierGenerator;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:IdentifierProperty.java

示例3: IdentifierProperty

import org.hibernate.id.IdentifierGenerator; //导入依赖的package包/类
/**
 * Construct a non-virtual identifier property.
 *
 * @param name The name of the property representing the identifier within
 * its owning entity.
 * @param node The node name to use for XML-based representation of this
 * property.
 * @param type The Hibernate Type for the identifier property.
 * @param embedded Is this an embedded identifier.
 * @param unsavedValue The value which, if found as the value on the identifier
 * property, represents new (i.e., un-saved) instances of the owning entity.
 * @param identifierGenerator The generator to use for id value generation.
 */
public IdentifierProperty(
		String name,
		String node,
		Type type,
		boolean embedded,
		IdentifierValue unsavedValue,
		IdentifierGenerator identifierGenerator) {
	super(name, node, type);
	this.virtual = false;
	this.embedded = embedded;
	this.hasIdentifierMapper = false;
	this.unsavedValue = unsavedValue;
	this.identifierGenerator = identifierGenerator;
	this.identifierAssignedByInsert = identifierGenerator instanceof PostInsertIdentifierGenerator;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:29,代码来源:IdentifierProperty.java

示例4: main

import org.hibernate.id.IdentifierGenerator; //导入依赖的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);
	}

}
 
开发者ID:8090boy,项目名称:gomall.la,代码行数:25,代码来源:UIDGenerator.java

示例5: getGeneratorType

import org.hibernate.id.IdentifierGenerator; //导入依赖的package包/类
private String getGeneratorType(AbstractEntityPersister entityPersister) {

        String generatorType = null;

        IdentifierGenerator generator = entityPersister != null ? entityPersister.getIdentifierGenerator() : null;
        if (generator != null) {
            if (generator instanceof IdentityGenerator)
                generatorType = "Identity";
            else if (generator instanceof Assigned)
                generatorType = "None";
            else
                generatorType = "KeyGenerator";
        }

        return generatorType;

    }
 
开发者ID:smysnk,项目名称:dockyard-controller,代码行数:18,代码来源:NewMetadataBuilder.java

示例6: ValueGenerationPlan

import org.hibernate.id.IdentifierGenerator; //导入依赖的package包/类
public ValueGenerationPlan(
		String propertyName,
		IdentifierGenerator subGenerator,
		Setter injector) {
	this.propertyName = propertyName;
	this.subGenerator = subGenerator;
	this.injector = injector;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:Component.java

示例7: bindSimpleIdentifier

import org.hibernate.id.IdentifierGenerator; //导入依赖的package包/类
private void bindSimpleIdentifier(SimpleIdentifierSource identifierSource, EntityBinding entityBinding) {
	final BasicAttributeBinding idAttributeBinding = doBasicSingularAttributeBindingCreation(
			identifierSource.getIdentifierAttributeSource(), entityBinding
	);

	entityBinding.getHierarchyDetails().getEntityIdentifier().setValueBinding( idAttributeBinding );
	IdGenerator generator = identifierSource.getIdentifierGeneratorDescriptor();
	if ( generator == null ) {
		Map<String, String> params = new HashMap<String, String>();
		params.put( IdentifierGenerator.ENTITY_NAME, entityBinding.getEntity().getName() );
		generator = new IdGenerator( "default_assign_identity_generator", "assigned", params );
	}
	entityBinding.getHierarchyDetails()
			.getEntityIdentifier()
			.setIdGenerator( generator );

	final org.hibernate.metamodel.relational.Value relationalValue = idAttributeBinding.getValue();

	if ( SimpleValue.class.isInstance( relationalValue ) ) {
		if ( !Column.class.isInstance( relationalValue ) ) {
			// this should never ever happen..
			throw new AssertionFailure( "Simple-id was not a column." );
		}
		entityBinding.getPrimaryTable().getPrimaryKey().addColumn( Column.class.cast( relationalValue ) );
	}
	else {
		for ( SimpleValue subValue : ( (Tuple) relationalValue ).values() ) {
			if ( Column.class.isInstance( subValue ) ) {
				entityBinding.getPrimaryTable().getPrimaryKey().addColumn( Column.class.cast( subValue ) );
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:Binder.java

示例8: buildIdentifierAttribute

import org.hibernate.id.IdentifierGenerator; //导入依赖的package包/类
/**
 * Generates the attribute representation of the identifier for a given entity mapping.
 *
 * @param mappedEntity The mapping definition of the entity.
 * @param generator The identifier value generator to use for this identifier.
 * @return The appropriate IdentifierProperty definition.
 */
public static IdentifierProperty buildIdentifierAttribute(
		PersistentClass mappedEntity,
		IdentifierGenerator generator) {
	String mappedUnsavedValue = mappedEntity.getIdentifier().getNullValue();
	Type type = mappedEntity.getIdentifier().getType();
	Property property = mappedEntity.getIdentifierProperty();
	
	IdentifierValue unsavedValue = UnsavedValueFactory.getUnsavedIdentifierValue(
			mappedUnsavedValue,
			getGetter( property ),
			type,
			getConstructor(mappedEntity)
		);

	if ( property == null ) {
		// this is a virtual id property...
		return new IdentifierProperty(
		        type,
				mappedEntity.hasEmbeddedIdentifier(),
				mappedEntity.hasIdentifierMapper(),
				unsavedValue,
				generator
			);
	}
	else {
		return new IdentifierProperty(
				property.getName(),
				property.getNodeName(),
				type,
				mappedEntity.hasEmbeddedIdentifier(),
				unsavedValue,
				generator
			);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:43,代码来源:PropertyFactory.java

示例9: createIdentifierGenerator

import org.hibernate.id.IdentifierGenerator; //导入依赖的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 );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:DefaultIdentifierGeneratorFactory.java

示例10: generateUniqueContentFolderID

import org.hibernate.id.IdentifierGenerator; //导入依赖的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();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:FileUtil.java

示例11: generateUniqueKey

import org.hibernate.id.IdentifierGenerator; //导入依赖的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();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:ForgotPasswordServlet.java

示例12: buildIdentifierProperty

import org.hibernate.id.IdentifierGenerator; //导入依赖的package包/类
/**
 * Generates an IdentifierProperty representation of the for a given entity mapping.
 *
 * @param mappedEntity The mapping definition of the entity.
 * @param generator The identifier value generator to use for this identifier.
 * @return The appropriate IdentifierProperty definition.
 */
public static IdentifierProperty buildIdentifierProperty(PersistentClass mappedEntity, IdentifierGenerator generator) {

	String mappedUnsavedValue = mappedEntity.getIdentifier().getNullValue();
	Type type = mappedEntity.getIdentifier().getType();
	Property property = mappedEntity.getIdentifierProperty();
	
	IdentifierValue unsavedValue = UnsavedValueFactory.getUnsavedIdentifierValue(
			mappedUnsavedValue,
			getGetter( property ),
			type,
			getConstructor(mappedEntity)
		);

	if ( property == null ) {
		// this is a virtual id property...
		return new IdentifierProperty(
		        type,
				mappedEntity.hasEmbeddedIdentifier(),
				mappedEntity.hasIdentifierMapper(),
				unsavedValue,
				generator
			);
	}
	else {
		return new IdentifierProperty(
				property.getName(),
				property.getNodeName(),
				type,
				mappedEntity.hasEmbeddedIdentifier(),
				unsavedValue,
				generator
			);
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:42,代码来源:PropertyFactory.java

示例13: getIdentifierGenerator

import org.hibernate.id.IdentifierGenerator; //导入依赖的package包/类
public IdentifierGenerator getIdentifierGenerator(String rootEntityName) {
    return sessionFactoryImplementor.getIdentifierGenerator(rootEntityName);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:4,代码来源:SessionFactoryWrapper.java

示例14: createIdentifierGenerator

import org.hibernate.id.IdentifierGenerator; //导入依赖的package包/类
public IdentifierGenerator createIdentifierGenerator(
IdentifierGeneratorFactory identifierGeneratorFactory,
Dialect dialect,
String defaultCatalog,
String defaultSchema,
RootClass rootClass) throws MappingException;
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:KeyValue.java

示例15: buildIdentifierGenerator

import org.hibernate.id.IdentifierGenerator; //导入依赖的package包/类
private IdentifierGenerator buildIdentifierGenerator(
		IdentifierGeneratorFactory identifierGeneratorFactory,
		Dialect dialect,
		String defaultCatalog,
		String defaultSchema,
		RootClass rootClass) throws MappingException {
	final boolean hasCustomGenerator = ! DEFAULT_ID_GEN_STRATEGY.equals( getIdentifierGeneratorStrategy() );
	if ( hasCustomGenerator ) {
		return super.createIdentifierGenerator(
				identifierGeneratorFactory, dialect, defaultCatalog, defaultSchema, rootClass
		);
	}

	final Class entityClass = rootClass.getMappedClass();
	final Class attributeDeclarer; // what class is the declarer of the composite pk attributes
	CompositeNestedGeneratedValueGenerator.GenerationContextLocator locator;

	// IMPL NOTE : See the javadoc discussion on CompositeNestedGeneratedValueGenerator wrt the
	//		various scenarios for which we need to account here
	if ( rootClass.getIdentifierMapper() != null ) {
		// we have the @IdClass / <composite-id mapped="true"/> case
		attributeDeclarer = resolveComponentClass();
	}
	else if ( rootClass.getIdentifierProperty() != null ) {
		// we have the "@EmbeddedId" / <composite-id name="idName"/> case
		attributeDeclarer = resolveComponentClass();
	}
	else {
		// we have the "straight up" embedded (again the hibernate term) component identifier
		attributeDeclarer = entityClass;
	}

	locator = new StandardGenerationContextLocator( rootClass.getEntityName() );
	final CompositeNestedGeneratedValueGenerator generator = new CompositeNestedGeneratedValueGenerator( locator );

	Iterator itr = getPropertyIterator();
	while ( itr.hasNext() ) {
		final Property property = (Property) itr.next();
		if ( property.getValue().isSimpleValue() ) {
			final SimpleValue value = (SimpleValue) property.getValue();

			if ( DEFAULT_ID_GEN_STRATEGY.equals( value.getIdentifierGeneratorStrategy() ) ) {
				// skip any 'assigned' generators, they would have been handled by
				// the StandardGenerationContextLocator
				continue;
			}

			final IdentifierGenerator valueGenerator = value.createIdentifierGenerator(
					identifierGeneratorFactory,
					dialect,
					defaultCatalog,
					defaultSchema,
					rootClass
			);
			generator.addGeneratedValuePlan(
					new ValueGenerationPlan(
							property.getName(),
							valueGenerator,
							injector( property, attributeDeclarer )
					)
			);
		}
	}
	return generator;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:66,代码来源:Component.java


注:本文中的org.hibernate.id.IdentifierGenerator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。