本文整理汇总了C#中IPersistentCollection类的典型用法代码示例。如果您正苦于以下问题:C# IPersistentCollection类的具体用法?C# IPersistentCollection怎么用?C# IPersistentCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPersistentCollection类属于命名空间,在下文中一共展示了IPersistentCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadingCollectionEntry
public LoadingCollectionEntry(IDataReader resultSet, ICollectionPersister persister, object key, IPersistentCollection collection)
{
this.resultSet = resultSet;
this.persister = persister;
this.key = key;
this.collection = collection;
}
示例2: ProcessReachableCollection
/// <summary>
/// Initialize the role of the collection.
/// </summary>
/// <param name="collection">The collection to be updated by reachibility. </param>
/// <param name="type">The type of the collection. </param>
/// <param name="entity">The owner of the collection. </param>
/// <param name="session">The session.</param>
public static void ProcessReachableCollection(IPersistentCollection collection, CollectionType type, object entity, ISessionImplementor session)
{
collection.Owner = entity;
CollectionEntry ce = session.PersistenceContext.GetCollectionEntry(collection);
if (ce == null)
{
// refer to comment in StatefulPersistenceContext.addCollection()
throw new HibernateException(string.Format("Found two representations of same collection: {0}", type.Role));
}
// The CollectionEntry.isReached() stuff is just to detect any silly users
// who set up circular or shared references between/to collections.
if (ce.IsReached)
{
// We've been here before
throw new HibernateException(string.Format("Found shared references to a collection: {0}", type.Role));
}
ce.IsReached = true;
ISessionFactoryImplementor factory = session.Factory;
ICollectionPersister persister = factory.GetCollectionPersister(type.Role);
ce.CurrentPersister = persister;
ce.CurrentKey = type.GetKeyOfOwner(entity, session); //TODO: better to pass the id in as an argument?
if (log.IsDebugEnabled)
{
log.Debug("Collection found: " +
MessageHelper.InfoString(persister, ce.CurrentKey, factory) + ", was: " +
MessageHelper.InfoString(ce.LoadedPersister, ce.LoadedKey, factory) +
(collection.WasInitialized ? " (initialized)" : " (uninitialized)"));
}
PrepareCollectionForUpdate(collection, ce);
}
示例3: Conj
public static IPersistentCollection Conj(IPersistentCollection collection, object obj)
{
if (collection == null)
return new PersistentList(obj);
return collection.Cons(obj);
}
示例4: CollectionUpdateAction
public CollectionUpdateAction(
IPersistentCollection collection, ICollectionPersister persister,
object key, bool emptySnapshot, ISessionImplementor session)
: base(persister, collection, key, session)
{
this.emptySnapshot = emptySnapshot;
}
示例5: ScheduledCollectionUpdate
/// <summary>
/// Initializes a new instance of <see cref="ScheduledCollectionUpdate"/>.
/// </summary>
/// <param name="collection">The <see cref="IPersistentCollection"/> to update.</param>
/// <param name="persister">The <see cref="ICollectionPersister"/> that is responsible for the persisting the Collection.</param>
/// <param name="id">The identifier of the Collection owner.</param>
/// <param name="emptySnapshot">Indicates if the Collection was empty when it was loaded.</param>
/// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param>
public ScheduledCollectionUpdate(IPersistentCollection collection, ICollectionPersister persister, object id,
bool emptySnapshot, ISessionImplementor session)
: base(persister, id, session)
{
_collection = collection;
_emptySnapshot = emptySnapshot;
}
示例6: MapCollectionChanges
public IList<PersistentCollectionChangeData> MapCollectionChanges(String referencingPropertyName,
IPersistentCollection newColl,
object oldColl,
object id)
{
return null;
}
示例7: MapCollectionChanges
public IList<PersistentCollectionChangeData> MapCollectionChanges(string referencingPropertyName,
IPersistentCollection newColl,
object oldColl,
object id)
{
return _delegate.MapCollectionChanges(referencingPropertyName, newColl, oldColl, id);
}
示例8: InitializeCollectionFromCache
/// <summary> Try to initialize a collection from the cache</summary>
private bool InitializeCollectionFromCache(object id, ICollectionPersister persister, IPersistentCollection collection, ISessionImplementor source)
{
if (!(source.EnabledFilters.Count == 0) && persister.IsAffectedByEnabledFilters(source))
{
log.Debug("disregarding cached version (if any) of collection due to enabled filters ");
return false;
}
bool useCache = persister.HasCache && ((source.CacheMode & CacheMode.Get) == CacheMode.Get);
if (!useCache)
{
return false;
}
else
{
ISessionFactoryImplementor factory = source.Factory;
CacheKey ck = new CacheKey(id, persister.KeyType, persister.Role, source.EntityMode, factory);
object ce = persister.Cache.Get(ck, source.Timestamp);
if (factory.Statistics.IsStatisticsEnabled)
{
if (ce == null)
{
factory.StatisticsImplementor.SecondLevelCacheMiss(persister.Cache.RegionName);
}
else
{
factory.StatisticsImplementor.SecondLevelCacheHit(persister.Cache.RegionName);
}
}
if (ce == null)
{
log.DebugFormat("Collection cache miss: {0}", ck);
}
else
{
log.DebugFormat("Collection cache hit: {0}", ck);
}
if (ce == null)
{
return false;
}
else
{
IPersistenceContext persistenceContext = source.PersistenceContext;
CollectionCacheEntry cacheEntry = (CollectionCacheEntry)persister.CacheEntryStructure.Destructure(ce, factory);
cacheEntry.Assemble(collection, persister, persistenceContext.GetCollectionOwner(id, persister));
persistenceContext.GetCollectionEntry(collection).PostInitialize(collection);
return true;
}
}
}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:60,代码来源:DefaultInitializeCollectionEventListener.cs
示例9: AbstractCollectionEvent
/// <summary> Constructs an AbstractCollectionEvent object. </summary>
/// <param name="collectionPersister">The collection persister.</param>
/// <param name="collection">The collection </param>
/// <param name="source">The Session source </param>
/// <param name="affectedOwner">The owner that is affected by this event; can be null if unavailable </param>
/// <param name="affectedOwnerId">
/// The ID for the owner that is affected by this event; can be null if unavailable
/// that is affected by this event; can be null if unavailable
/// </param>
protected AbstractCollectionEvent(ICollectionPersister collectionPersister, IPersistentCollection collection,
IEventSource source, object affectedOwner, object affectedOwnerId) : base(source)
{
this.collection = collection;
this.affectedOwner = affectedOwner;
this.affectedOwnerId = affectedOwnerId;
affectedOwnerEntityName = GetAffectedOwnerEntityName(collectionPersister, affectedOwner, source);
}
示例10: ProcessNeverReferencedCollection
private static void ProcessNeverReferencedCollection(IPersistentCollection coll, ISessionImplementor session)
{
CollectionEntry entry = session.PersistenceContext.GetCollectionEntry(coll);
log.Debug("Found collection with unloaded owner: " + MessageHelper.InfoString(entry.LoadedPersister, entry.LoadedKey, session.Factory));
entry.CurrentPersister = entry.LoadedPersister;
entry.CurrentKey = entry.LoadedKey;
PrepareCollectionForUpdate(coll, entry);
}
示例11: ProcessUnreachableCollection
/// <summary>
/// Record the fact that this collection was dereferenced
/// </summary>
/// <param name="coll">The collection to be updated by unreachability. </param>
/// <param name="session">The session.</param>
public static void ProcessUnreachableCollection(IPersistentCollection coll, ISessionImplementor session)
{
if (coll.Owner == null)
{
ProcessNeverReferencedCollection(coll, session);
}
else
{
ProcessDereferencedCollection(coll, session);
}
}
示例12: PersistentCollectionChangeWorkUnit
public PersistentCollectionChangeWorkUnit(ISessionImplementor sessionImplementor, String entityName,
AuditConfiguration auditCfg, IPersistentCollection collection,
CollectionEntry collectionEntry, Object snapshot, Object id,
String referencingPropertyName)
: base(sessionImplementor, entityName, auditCfg,
new PersistentCollectionChangeWorkUnitId(id, collectionEntry.Role))
{
this.ReferencingPropertyName = referencingPropertyName;
collectionChanges = auditCfg.EntCfg[EntityName].PropertyMapper
.MapCollectionChanges(referencingPropertyName, collection, snapshot, id);
}
示例13: EvictCollection
private void EvictCollection(IPersistentCollection collection)
{
CollectionEntry ce = (CollectionEntry)Session.PersistenceContext.CollectionEntries[collection];
Session.PersistenceContext.CollectionEntries.Remove(collection);
if (log.IsDebugEnabled)
log.Debug("evicting collection: " + MessageHelper.InfoString(ce.LoadedPersister, ce.LoadedKey, Session.Factory));
if (ce.LoadedPersister != null && ce.LoadedKey != null)
{
//TODO: is this 100% correct?
Session.PersistenceContext.CollectionsByKey.Remove(new CollectionKey(ce.LoadedPersister, ce.LoadedKey, Session.EntityMode));
}
}
示例14: CollectionRemoveAction
/// <summary>
/// Removes a persistent collection from its loaded owner.
/// </summary>
/// <param name="collection">The collection to to remove; must be non-null </param>
/// <param name="persister"> The collection's persister </param>
/// <param name="id">The collection key </param>
/// <param name="emptySnapshot">Indicates if the snapshot is empty </param>
/// <param name="session">The session </param>
/// <remarks>Use this constructor when the collection is non-null.</remarks>
public CollectionRemoveAction(IPersistentCollection collection, ICollectionPersister persister, object id,
bool emptySnapshot, ISessionImplementor session)
: base(persister, collection, id, session)
{
if (collection == null)
{
throw new AssertionFailure("collection == null");
}
this.emptySnapshot = emptySnapshot;
affectedOwner = session.PersistenceContext.GetLoadedCollectionOwnerOrNull(collection);
}
示例15: ProcessDereferencedCollection
private static void ProcessDereferencedCollection(IPersistentCollection coll, ISessionImplementor session)
{
IPersistenceContext persistenceContext = session.PersistenceContext;
CollectionEntry entry = persistenceContext.GetCollectionEntry(coll);
ICollectionPersister loadedPersister = entry.LoadedPersister;
if (log.IsDebugEnabled && loadedPersister != null)
log.Debug("Collection dereferenced: " + MessageHelper.InfoString(loadedPersister, entry.LoadedKey, session.Factory));
// do a check
bool hasOrphanDelete = loadedPersister != null && loadedPersister.HasOrphanDelete;
if (hasOrphanDelete)
{
object ownerId = loadedPersister.OwnerEntityPersister.GetIdentifier(coll.Owner, session.EntityMode);
// TODO NH Different behavior
//if (ownerId == null)
//{
// // the owning entity may have been deleted and its identifier unset due to
// // identifier-rollback; in which case, try to look up its identifier from
// // the persistence context
// if (session.Factory.Settings.IsIdentifierRollbackEnabled)
// {
// EntityEntry ownerEntry = persistenceContext.GetEntry(coll.Owner);
// if (ownerEntry != null)
// {
// ownerId = ownerEntry.Id;
// }
// }
// if (ownerId == null)
// {
// throw new AssertionFailure("Unable to determine collection owner identifier for orphan-delete processing");
// }
//}
EntityKey key = new EntityKey(ownerId, loadedPersister.OwnerEntityPersister, session.EntityMode);
object owner = persistenceContext.GetEntity(key);
if (owner == null)
{
throw new AssertionFailure("collection owner not associated with session: " + loadedPersister.Role);
}
EntityEntry e = persistenceContext.GetEntry(owner);
//only collections belonging to deleted entities are allowed to be dereferenced in the case of orphan delete
if (e != null && e.Status != Status.Deleted && e.Status != Status.Gone)
{
throw new HibernateException("A collection with cascade=\"all-delete-orphan\" was no longer referenced by the owning entity instance: " + loadedPersister.Role);
}
}
// do the work
entry.CurrentPersister = null;
entry.CurrentKey = null;
PrepareCollectionForUpdate(coll, entry, session.EntityMode, session.Factory);
}