本文整理匯總了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;
}
}