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


Java Type.isEqual方法代碼示例

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


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

示例1: identityRemove

import org.hibernate.type.Type; //導入方法依賴的package包/類
/**
 * Removes entity entries that have an equal identifier with the incoming entity instance
 *
 * @param list The list containing the entity instances
 * @param entityInstance The entity instance to match elements.
 * @param entityName The entity name
 * @param session The session
 */
public static void identityRemove(
		Collection list,
		Object entityInstance,
		String entityName,
		SessionImplementor session) {

	if ( entityInstance != null && ForeignKeys.isNotTransient( entityName, entityInstance, null, session ) ) {
		final EntityPersister entityPersister = session.getFactory().getEntityPersister( entityName );
		final Type idType = entityPersister.getIdentifierType();

		final Serializable idOfCurrent = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, entityInstance, session );
		final Iterator itr = list.iterator();
		while ( itr.hasNext() ) {
			final Serializable idOfOld = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, itr.next(), session );
			if ( idType.isEqual( idOfCurrent, idOfOld, session.getFactory() ) ) {
				itr.remove();
				break;
			}
		}

	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:AbstractPersistentCollection.java

示例2: checkNaturalId

import org.hibernate.type.Type; //導入方法依賴的package包/類
private void checkNaturalId(
		EntityPersister persister,
		EntityEntry entry,
		Object[] current,
		Object[] loaded,
		SessionImplementor session) {
	if ( persister.hasNaturalIdentifier() && entry.getStatus() != Status.READ_ONLY ) {
		if ( !persister.getEntityMetamodel().hasImmutableNaturalId() ) {
			// SHORT-CUT: if the natural id is mutable (!immutable), no need to do the below checks
			// EARLY EXIT!!!
			return;
		}

		final int[] naturalIdentifierPropertiesIndexes = persister.getNaturalIdentifierProperties();
		final Type[] propertyTypes = persister.getPropertyTypes();
		final boolean[] propertyUpdateability = persister.getPropertyUpdateability();

		final Object[] snapshot = loaded == null
				? session.getPersistenceContext().getNaturalIdSnapshot( entry.getId(), persister )
				: session.getPersistenceContext().getNaturalIdHelper().extractNaturalIdValues( loaded, persister );

		for ( int i = 0; i < naturalIdentifierPropertiesIndexes.length; i++ ) {
			final int naturalIdentifierPropertyIndex = naturalIdentifierPropertiesIndexes[i];
			if ( propertyUpdateability[naturalIdentifierPropertyIndex] ) {
				// if the given natural id property is updatable (mutable), there is nothing to check
				continue;
			}

			final Type propertyType = propertyTypes[naturalIdentifierPropertyIndex];
			if ( !propertyType.isEqual( current[naturalIdentifierPropertyIndex], snapshot[i] ) ) {
				throw new HibernateException(
						String.format(
								"An immutable natural identifier of entity %s was altered from %s to %s",
								persister.getEntityName(),
								propertyTypes[naturalIdentifierPropertyIndex].toLoggableString(
										snapshot[i],
										session.getFactory()
								),
								propertyTypes[naturalIdentifierPropertyIndex].toLoggableString(
										current[naturalIdentifierPropertyIndex],
										session.getFactory()
								)
						)
				);
			}
		}
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:49,代碼來源:DefaultFlushEntityEventListener.java


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