当前位置: 首页>>代码示例>>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;未经允许,请勿转载。