• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java IdentifierGeneratorFactory类的典型用法和代码示例

java 1次浏览

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

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

示例1: createIdentifierGenerator

点赞 3

import org.hibernate.id.factory.IdentifierGeneratorFactory; //导入依赖的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: getIdentifierGeneratorFactory

点赞 2

import org.hibernate.id.factory.IdentifierGeneratorFactory; //导入依赖的package包/类
public IdentifierGeneratorFactory getIdentifierGeneratorFactory() {
    return sessionFactoryImplementor.getIdentifierGeneratorFactory();
}
 

开发者ID:zhaojunfei,
项目名称:lemon,
代码行数:4,
代码来源:SessionFactoryWrapper.java

示例3: createIdentifierGenerator

点赞 2

import org.hibernate.id.factory.IdentifierGeneratorFactory; //导入依赖的package包/类
public IdentifierGenerator createIdentifierGenerator(
IdentifierGeneratorFactory identifierGeneratorFactory,
Dialect dialect,
String defaultCatalog,
String defaultSchema,
RootClass rootClass) throws MappingException;
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:7,
代码来源:KeyValue.java

示例4: buildIdentifierGenerator

点赞 2

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

示例5: createIdentifierGenerator

点赞 2

import org.hibernate.id.factory.IdentifierGeneratorFactory; //导入依赖的package包/类
public IdentifierGenerator createIdentifierGenerator(
		IdentifierGeneratorFactory identifierGeneratorFactory,
		Dialect dialect, 
		String defaultCatalog, 
		String defaultSchema, 
		RootClass rootClass) throws MappingException {
	
	Properties params = new Properties();
	
	//if the hibernate-mapping did not specify a schema/catalog, use the defaults
	//specified by properties - but note that if the schema/catalog were specified
	//in hibernate-mapping, or as params, they will already be initialized and
	//will override the values set here (they are in identifierGeneratorProperties)
	if ( defaultSchema!=null ) {
		params.setProperty(PersistentIdentifierGenerator.SCHEMA, defaultSchema);
	}
	if ( defaultCatalog!=null ) {
		params.setProperty(PersistentIdentifierGenerator.CATALOG, defaultCatalog);
	}
	
	//pass the entity-name, if not a collection-id
	if (rootClass!=null) {
		params.setProperty( IdentifierGenerator.ENTITY_NAME, rootClass.getEntityName() );
		params.setProperty( IdentifierGenerator.JPA_ENTITY_NAME, rootClass.getJpaEntityName() );
	}
	
	//init the table here instead of earlier, so that we can get a quoted table name
	//TODO: would it be better to simply pass the qualified table name, instead of
	//      splitting it up into schema/catalog/table names
	String tableName = getTable().getQuotedName(dialect);
	params.setProperty( PersistentIdentifierGenerator.TABLE, tableName );
	
	//pass the column name (a generated id almost always has a single column)
	String columnName = ( (Column) getColumnIterator().next() ).getQuotedName(dialect);
	params.setProperty( PersistentIdentifierGenerator.PK, columnName );
	
	if (rootClass!=null) {
		StringBuilder tables = new StringBuilder();
		Iterator iter = rootClass.getIdentityTables().iterator();
		while ( iter.hasNext() ) {
			Table table= (Table) iter.next();
			tables.append( table.getQuotedName(dialect) );
			if ( iter.hasNext() ) tables.append(", ");
		}
		params.setProperty( PersistentIdentifierGenerator.TABLES, tables.toString() );
	}
	else {
		params.setProperty( PersistentIdentifierGenerator.TABLES, tableName );
	}

	if (identifierGeneratorProperties!=null) {
		params.putAll(identifierGeneratorProperties);
	}

	// TODO : we should pass along all settings once "config lifecycle" is hashed out...
	params.put(
			Environment.PREFER_POOLED_VALUES_LO,
			mappings.getConfigurationProperties().getProperty( Environment.PREFER_POOLED_VALUES_LO, "false" )
	);

	identifierGeneratorFactory.setDialect( dialect );
	return identifierGeneratorFactory.createIdentifierGenerator( identifierGeneratorStrategy, getType(), params );
	
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:65,
代码来源:SimpleValue.java

示例6: isIdentityColumn

点赞 2

import org.hibernate.id.factory.IdentifierGeneratorFactory; //导入依赖的package包/类
public boolean isIdentityColumn(IdentifierGeneratorFactory identifierGeneratorFactory, Dialect dialect) {
	identifierGeneratorFactory.setDialect( dialect );
	return identifierGeneratorFactory.getIdentifierGeneratorClass( identifierGeneratorStrategy )
			.equals( IdentityGenerator.class );
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:6,
代码来源:SimpleValue.java

示例7: createIdentifierGenerator

点赞 2

import org.hibernate.id.factory.IdentifierGeneratorFactory; //导入依赖的package包/类
IdentifierGenerator createIdentifierGenerator(
		IdGenerator idGenerator,
		IdentifierGeneratorFactory identifierGeneratorFactory,
		Properties properties) {
	Properties params = new Properties();
	params.putAll( properties );

	// use the schema/catalog specified by getValue().getTable() - but note that
	// if the schema/catalog were specified as params, they will already be initialized and
	//will override the values set here (they are in idGenerator.getParameters().)
	Schema schema = getValue().getTable().getSchema();
	if ( schema != null ) {
		if ( schema.getName().getSchema() != null ) {
			params.setProperty( PersistentIdentifierGenerator.SCHEMA, schema.getName().getSchema().getName() );
		}
		if ( schema.getName().getCatalog() != null ) {
			params.setProperty( PersistentIdentifierGenerator.CATALOG, schema.getName().getCatalog().getName() );
		}
	}

	// TODO: not sure how this works for collection IDs...
	//pass the entity-name, if not a collection-id
	//if ( rootClass!=null) {
		params.setProperty( IdentifierGenerator.ENTITY_NAME, getContainer().seekEntityBinding().getEntity().getName() );
	//}

	//init the table here instead of earlier, so that we can get a quoted table name
	//TODO: would it be better to simply pass the qualified table name, instead of
	//      splitting it up into schema/catalog/table names
	String tableName = getValue().getTable().getQualifiedName( identifierGeneratorFactory.getDialect() );
	params.setProperty( PersistentIdentifierGenerator.TABLE, tableName );

	//pass the column name (a generated id almost always has a single column)
	if ( getSimpleValueSpan() > 1 ) {
		throw new MappingException(
				"A SimpleAttributeBinding used for an identifier has more than 1 Value: " + getAttribute().getName()
		);
	}
	SimpleValue simpleValue = (SimpleValue) getValue();
	if ( !Column.class.isInstance( simpleValue ) ) {
		throw new MappingException(
				"Cannot create an IdentifierGenerator because the value is not a column: " +
						simpleValue.toLoggableString()
		);
	}
	params.setProperty(
			PersistentIdentifierGenerator.PK,
			( (Column) simpleValue ).getColumnName().encloseInQuotesIfQuoted(
					identifierGeneratorFactory.getDialect()
			)
	);

	// TODO: is this stuff necessary for SimpleValue???
	//if (rootClass!=null) {
	//	StringBuffer tables = new StringBuffer();
	//	Iterator iter = rootClass.getIdentityTables().iterator();
	//	while ( iter.hasNext() ) {
	//		Table table= (Table) iter.next();
	//		tables.append( table.getQuotedName(dialect) );
	//		if ( iter.hasNext() ) tables.append(", ");
	//	}
	//	params.setProperty( PersistentIdentifierGenerator.TABLES, tables.toString() );
	//}
	//else {
	params.setProperty( PersistentIdentifierGenerator.TABLES, tableName );
	//}

	params.putAll( idGenerator.getParameters() );

	return identifierGeneratorFactory.createIdentifierGenerator(
			idGenerator.getStrategy(), getHibernateTypeDescriptor().getResolvedTypeMapping(), params
	);
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:74,
代码来源:BasicAttributeBinding.java

示例8: createIdentifierGenerator

点赞 2

import org.hibernate.id.factory.IdentifierGeneratorFactory; //导入依赖的package包/类
public IdentifierGenerator createIdentifierGenerator(IdentifierGeneratorFactory factory, Properties properties) {
	if ( idGenerator != null ) {
		identifierGenerator = attributeBinding.createIdentifierGenerator( idGenerator, factory, properties );
	}
	return identifierGenerator;
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:7,
代码来源:EntityIdentifier.java

示例9: getIdentifierGeneratorFactory

点赞 2

import org.hibernate.id.factory.IdentifierGeneratorFactory; //导入依赖的package包/类
@Override
public IdentifierGeneratorFactory getIdentifierGeneratorFactory() {
	return identifierGeneratorFactory;
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:5,
代码来源:MetadataImpl.java

示例10: getIdentifierGeneratorFactory

点赞 2

import org.hibernate.id.factory.IdentifierGeneratorFactory; //导入依赖的package包/类
public IdentifierGeneratorFactory getIdentifierGeneratorFactory() {
	return null;
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:4,
代码来源:SessionFactoryImpl.java

示例11: getIdentifierGeneratorFactory

点赞 1

import org.hibernate.id.factory.IdentifierGeneratorFactory; //导入依赖的package包/类
/**
 * Allow access to the id generator factory, though this is only needed/allowed from configuration.
 *
 * @return Access to the identifier generator factory
 *
 * @deprecated temporary solution 
 */
@Deprecated
public IdentifierGeneratorFactory getIdentifierGeneratorFactory();
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:10,
代码来源:Mapping.java

示例12: isIdentityColumn

点赞 1

import org.hibernate.id.factory.IdentifierGeneratorFactory; //导入依赖的package包/类
public boolean isIdentityColumn(IdentifierGeneratorFactory identifierGeneratorFactory, Dialect dialect); 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:2,
代码来源:KeyValue.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)