當前位置: 首頁>>代碼示例>>Java>>正文


Java Type.getHashCode方法代碼示例

本文整理匯總了Java中org.hibernate.type.Type.getHashCode方法的典型用法代碼示例。如果您正苦於以下問題:Java Type.getHashCode方法的具體用法?Java Type.getHashCode怎麽用?Java Type.getHashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hibernate.type.Type的用法示例。


在下文中一共展示了Type.getHashCode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: CachedNaturalId

import org.hibernate.type.Type; //導入方法依賴的package包/類
public CachedNaturalId(EntityPersister persister, Object[] values) {
	this.persister = persister;
	this.values = values;

	final int prime = 31;
	int hashCodeCalculation = 1;
	hashCodeCalculation = prime * hashCodeCalculation + persister.hashCode();

	final int[] naturalIdPropertyIndexes = persister.getNaturalIdentifierProperties();
	naturalIdTypes = new Type[ naturalIdPropertyIndexes.length ];
	int i = 0;
	for ( int naturalIdPropertyIndex : naturalIdPropertyIndexes ) {
		final Type type = persister.getPropertyType( persister.getPropertyNames()[ naturalIdPropertyIndex ] );
		naturalIdTypes[i] = type;
		final int elementHashCode = values[i] == null ? 0 :type.getHashCode( values[i], persister.getFactory() );
		hashCodeCalculation = prime * hashCodeCalculation + elementHashCode;
		i++;
	}

	this.hashCode = hashCodeCalculation;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:NaturalIdXrefDelegate.java

示例2: NaturalIdCacheKey

import org.hibernate.type.Type; //導入方法依賴的package包/類
/**
 * Construct a new key for a caching natural identifier resolutions into the second level cache.
 * Note that an entity name should always be the root entity name, not a subclass entity name.
 *
 * @param naturalIdValues The naturalIdValues associated with the cached data
 * @param persister The persister for the entity
 * @param session The originating session
 */
public NaturalIdCacheKey(
		final Object[] naturalIdValues,
		final EntityPersister persister,
		final SessionImplementor session) {

	this.entityName = persister.getRootEntityName();
	this.tenantId = session.getTenantIdentifier();

	this.naturalIdValues = new Serializable[naturalIdValues.length];

	final SessionFactoryImplementor factory = session.getFactory();
	final int[] naturalIdPropertyIndexes = persister.getNaturalIdentifierProperties();
	final Type[] propertyTypes = persister.getPropertyTypes();

	final int prime = 31;
	int result = 1;
	result = prime * result + ( ( this.entityName == null ) ? 0 : this.entityName.hashCode() );
	result = prime * result + ( ( this.tenantId == null ) ? 0 : this.tenantId.hashCode() );
	for ( int i = 0; i < naturalIdValues.length; i++ ) {
		final int naturalIdPropertyIndex = naturalIdPropertyIndexes[i];
		final Type type = propertyTypes[naturalIdPropertyIndex];
		final Object value = naturalIdValues[i];

		result = prime * result + (value != null ? type.getHashCode( value, factory ) : 0);

		// The natural id may not be fully resolved in some situations.  See HHH-7513 for one of them
		// (re-attaching a mutable natural id uses a database snapshot and hydration does not resolve associations).
		// TODO: The snapshot should probably be revisited at some point.  Consider semi-resolving, hydrating, etc.
		if (type instanceof EntityType && type.getSemiResolvedType( factory ).getReturnedClass().isInstance( value )) {
			this.naturalIdValues[i] = (Serializable) value;
		}
		else {
			this.naturalIdValues[i] = type.disassemble( value, session, null );
		}
	}

	this.hashCode = result;
	initTransients();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:48,代碼來源:NaturalIdCacheKey.java

示例3: calculateHashCode

import org.hibernate.type.Type; //導入方法依賴的package包/類
private int calculateHashCode(Type type, SessionFactoryImplementor factory) {
	int result = type.getHashCode( key, factory );
	result = 31 * result + (tenantId != null ? tenantId.hashCode() : 0);
	return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:6,代碼來源:CacheKey.java


注:本文中的org.hibernate.type.Type.getHashCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。