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


Java EntityPersister.getNaturalIdentifierSnapshot方法代码示例

本文整理汇总了Java中org.hibernate.persister.entity.EntityPersister.getNaturalIdentifierSnapshot方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPersister.getNaturalIdentifierSnapshot方法的具体用法?Java EntityPersister.getNaturalIdentifierSnapshot怎么用?Java EntityPersister.getNaturalIdentifierSnapshot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.persister.entity.EntityPersister的用法示例。


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

示例1: getNaturalIdSnapshot

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
@Override
public Object[] getNaturalIdSnapshot(Serializable id, EntityPersister persister) throws HibernateException {
	if ( !persister.hasNaturalIdentifier() ) {
		return null;
	}

	persister = locateProperPersister( persister );

	// let's first see if it is part of the natural id cache...
	final Object[] cachedValue = naturalIdHelper.findCachedNaturalId( persister, id );
	if ( cachedValue != null ) {
		return cachedValue;
	}

	// check to see if the natural id is mutable/immutable
	if ( persister.getEntityMetamodel().hasImmutableNaturalId() ) {
		// an immutable natural-id is not retrieved during a normal database-snapshot operation...
		final Object[] dbValue = persister.getNaturalIdentifierSnapshot( id, session );
		naturalIdHelper.cacheNaturalIdCrossReferenceFromLoad(
				persister,
				id,
				dbValue
		);
		return dbValue;
	}
	else {
		// for a mutable natural there is a likelihood that the the information will already be
		// snapshot-cached.
		final int[] props = persister.getNaturalIdentifierProperties();
		final Object[] entitySnapshot = getDatabaseSnapshot( id, persister );
		if ( entitySnapshot == NO_ROW || entitySnapshot == null ) {
			return null;
		}

		final Object[] naturalIdSnapshotSubSet = new Object[ props.length ];
		for ( int i = 0; i < props.length; i++ ) {
			naturalIdSnapshotSubSet[i] = entitySnapshot[ props[i] ];
		}
		naturalIdHelper.cacheNaturalIdCrossReferenceFromLoad(
				persister,
				id,
				naturalIdSnapshotSubSet
		);
		return naturalIdSnapshotSubSet;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:47,代码来源:StatefulPersistenceContext.java


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