本文整理汇总了C#中NHibernate.Type.CollectionType类的典型用法代码示例。如果您正苦于以下问题:C# CollectionType类的具体用法?C# CollectionType怎么用?C# CollectionType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CollectionType类属于NHibernate.Type命名空间,在下文中一共展示了CollectionType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessCollection
protected override object ProcessCollection(object collection, CollectionType type)
{
if (collection != null)
{
SessionImpl session = Session;
IPersistentCollection coll;
if (type.IsArrayType)
{
coll = session.GetArrayHolder(collection);
// if no array holder we found an unwrappered array (this can't occur,
// because we now always call wrap() before getting to here)
// return (ah==null) ? true : searchForDirtyCollections(ah, type);
}
else
{
// if not wrappered yet, its dirty (this can't occur, because
// we now always call wrap() before getting to here)
// return ( ! (obj is AbstractPersistentCollection) ) ?
// true : SearchForDirtyCollections( (AbstractPersistentCollection) obj, type );
coll = (IPersistentCollection) collection;
}
if (coll.IsDirty)
{
_dirty = true;
return null; // NOTE: early exit
}
}
return null;
}
示例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: ProcessCollection
internal override object ProcessCollection(object collection, CollectionType type)
{
if (collection != null)
{
ISessionImplementor session = Session;
IPersistentCollection persistentCollection;
if (type.IsArrayType)
{
persistentCollection = session.PersistenceContext.GetCollectionHolder(collection);
// if no array holder we found an unwrappered array (this can't occur,
// because we now always call wrap() before getting to here)
// return (ah==null) ? true : searchForDirtyCollections(ah, type);
}
else
{
// if not wrappered yet, its dirty (this can't occur, because
// we now always call wrap() before getting to here)
// return ( ! (obj instanceof PersistentCollection) ) ?
//true : searchForDirtyCollections( (PersistentCollection) obj, type );
persistentCollection = (IPersistentCollection)collection;
}
if (persistentCollection.IsDirty)
{
//we need to check even if it was not initialized, because of delayed adds!
dirty = true;
return null; //NOTE: EARLY EXIT!
}
}
return null;
}
示例4: ProcessArrayOrNewCollection
private object ProcessArrayOrNewCollection(object collection, CollectionType collectionType)
{
if (collection == null)
{
return null;
}
ICollectionPersister persister = Session.GetCollectionPersister(collectionType.Role);
if (collectionType.IsArrayType)
{
PersistentArrayHolder ah = Session.GetArrayHolder(collection);
if (ah == null)
{
ah = new PersistentArrayHolder(Session, collection);
Session.AddNewCollection(ah, persister);
Session.AddArrayHolder(ah);
}
return null;
}
else
{
IPersistentCollection persistentCollection = collectionType.Wrap(Session, collection);
Session.AddNewCollection(persistentCollection, persister);
if (log.IsDebugEnabled)
{
log.Debug("Wrapped collection in role: " + collectionType.Role);
}
return persistentCollection; //Force a substitution!
}
}
示例5: ProcessCollection
protected override object ProcessCollection(object collection, CollectionType type)
{
SessionImpl session = Session;
object key = Key;
ICollectionPersister persister = session.GetCollectionPersister(type.Role);
session.RemoveCollection(persister, key);
if (collection != null && (collection is IPersistentCollection))
{
IPersistentCollection wrapper = collection as IPersistentCollection;
wrapper.SetCurrentSession(session);
if (wrapper.WasInitialized)
{
session.AddNewCollection(wrapper, persister);
}
else
{
session.ReattachCollection(wrapper, wrapper.CollectionSnapshot);
}
}
else
{
// otherwise a null or brand new collection
// this will also (inefficiently) handle arrays, which
// have no snapshot, so we can't do any better
//processArrayOrNewCollection(collection, type);
}
return null;
}
示例6: ProcessCollection
internal override object ProcessCollection(object collection, CollectionType type)
{
if (collection != null)
EvictCollection(collection, type);
return null;
}
示例7: ProcessCollection
protected override object ProcessCollection(object collection, CollectionType type)
{
if (collection != null)
{
Session.EvictCollection(collection, type);
}
return null;
}
示例8: ProcessCollection
internal override object ProcessCollection(object collection, CollectionType type)
{
ISessionImplementor session = Session;
ICollectionPersister persister = session.Factory.GetCollectionPersister(type.Role);
if (collection == null)
{
//do nothing
}
else
{
IPersistentCollection persistentCollection = collection as IPersistentCollection;
if (persistentCollection != null)
{
if (persistentCollection.SetCurrentSession(session))
{
ICollectionSnapshot snapshot = persistentCollection.CollectionSnapshot;
if (IsOwnerUnchanged(snapshot, persister, ExtractCollectionKeyFromOwner(persister)))
{
// a "detached" collection that originally belonged to the same entity
if (persistentCollection.IsDirty)
{
throw new HibernateException("reassociated object has dirty collection");
}
ReattachCollection(persistentCollection, snapshot);
}
else
{
// a "detached" collection that belonged to a different entity
throw new HibernateException("reassociated object has dirty collection reference");
}
}
else
{
// a collection loaded in the current session
// can not possibly be the collection belonging
// to the entity passed to update()
throw new HibernateException("reassociated object has dirty collection reference");
}
}
else
{
// brand new collection
//TODO: or an array!! we can't lock objects with arrays now??
throw new HibernateException("reassociated object has dirty collection reference (or an array)");
}
}
return null;
}
示例9: ProcessCollection
protected override object ProcessCollection(object collection, CollectionType collectionType)
{
if (collection != null && (collection is IPersistentCollection))
{
IPersistentCollection coll = collection as IPersistentCollection;
if (coll.SetCurrentSession(Session))
{
Session.ReattachCollection(coll, coll.CollectionSnapshot);
}
return null;
}
else
{
return ProcessArrayOrNewCollection(collection, collectionType);
}
}
示例10: ProcessCollection
protected override object ProcessCollection(object collection, CollectionType type)
{
ICollectionPersister persister = Session.GetCollectionPersister(type.Role);
if (collection == null)
{
// Do nothing
}
else if (collection is IPersistentCollection)
{
IPersistentCollection coll = (IPersistentCollection) collection;
if (coll.SetCurrentSession(Session))
{
ICollectionSnapshot snapshot = coll.CollectionSnapshot;
if (SessionImpl.IsOwnerUnchanged(snapshot, persister, this.Key))
{
// a "detached" collection that originally belonged to the same entity
if (coll.IsDirty)
{
throw new HibernateException("reassociated object has dirty collection");
}
Session.ReattachCollection(coll, snapshot);
}
else
{
// a "detached" collection that belonged to a different entity
throw new HibernateException("reassociated object has dirty collection reference");
}
}
else
{
// a collection loaded in the current session
// can not possibly be the collection belonging
// to the entity passed to update()
throw new HibernateException("reassociated object has dirty collection reference");
}
}
else
{
// brand new collection
//TODO: or an array!! we can't lock objects with arrays now??
throw new HibernateException("reassociated object has dirty collection reference");
}
return null;
}
示例11: ProcessCollection
internal override object ProcessCollection(object collection, CollectionType collectionType)
{
IPersistentCollection coll = collection as IPersistentCollection;
if (coll != null)
{
ISessionImplementor session = Session;
if (coll.SetCurrentSession(session))
{
ReattachCollection(coll, collectionType);
}
return null;
}
else
{
return ProcessArrayOrNewCollection(collection, collectionType);
}
}
示例12: ReattachCollection
/// <summary>
/// Reattach a detached (disassociated) initialized or uninitialized
/// collection wrapper, using a snapshot carried with the collection wrapper
/// </summary>
protected internal void ReattachCollection(IPersistentCollection collection, CollectionType type)
{
if (collection.WasInitialized)
{
ICollectionPersister collectionPersister = Session.Factory.GetCollectionPersister(type.Role);
Session.PersistenceContext.AddInitializedDetachedCollection(collectionPersister, collection);
}
else
{
if (!IsCollectionSnapshotValid(collection))
{
throw new HibernateException("could not reassociate uninitialized transient collection");
}
ICollectionPersister collectionPersister = Session.Factory.GetCollectionPersister(collection.Role);
Session.PersistenceContext.AddUninitializedDetachedCollection(collectionPersister, collection);
}
}
示例13: ProcessCollection
internal override object ProcessCollection(object collection, CollectionType type)
{
if (collection == CollectionType.UnfetchedCollection)
{
return null;
}
IEventSource session = Session;
ICollectionPersister persister = session.Factory.GetCollectionPersister(type.Role);
object collectionKey = ExtractCollectionKeyFromOwner(persister);
IPersistentCollection wrapper = collection as IPersistentCollection;
if (wrapper != null)
{
if (wrapper.SetCurrentSession(session))
{
//a "detached" collection!
ICollectionSnapshot snapshot = wrapper.CollectionSnapshot;
if (!IsOwnerUnchanged(snapshot, persister, collectionKey))
{
// if the collection belonged to a different entity,
// clean up the existing state of the collection
RemoveCollection(persister, collectionKey, session);
}
ReattachCollection(wrapper, snapshot);
}
else
{
// a collection loaded in the current session
// can not possibly be the collection belonging
// to the entity passed to update()
RemoveCollection(persister, collectionKey, session);
}
}
else
{
// null or brand new collection
// this will also (inefficiently) handle arrays, which have
// no snapshot, so we can't do any better
RemoveCollection(persister, collectionKey, session);
}
return null;
}
示例14: EvictCollection
public virtual void EvictCollection(object value, CollectionType type)
{
IPersistentCollection pc;
if (type.IsArrayType)
{
pc = Session.PersistenceContext.RemoveCollectionHolder(value);
}
else if (value is IPersistentCollection)
{
pc = (IPersistentCollection)value;
}
else
{
return; //EARLY EXIT!
}
IPersistentCollection collection = pc;
if (collection.UnsetSession(Session))
EvictCollection(collection);
}
示例15: ProcessCollection
protected override object ProcessCollection(object collection, CollectionType type)
{
ICollectionPersister persister = Session.GetCollectionPersister(type.Role);
if (collection is IPersistentCollection)
{
IPersistentCollection wrapper = (IPersistentCollection) collection;
if (wrapper.SetCurrentSession(Session))
{
//a "detached" collection!
ICollectionSnapshot snapshot = wrapper.CollectionSnapshot;
if (!SessionImpl.IsOwnerUnchanged(snapshot, persister, Key))
{
// if the collection belonged to a different entity,
// clean up the existing state of the collection
Session.RemoveCollection(persister, Key);
}
Session.ReattachCollection(wrapper, snapshot);
}
else
{
// a collection loaded in the current session
// can not possibly be the collection belonging
// to the entity passed to update()
Session.RemoveCollection(persister, Key);
}
}
else
{
// null or brand new collection
// this will also (inefficiently) handle arrays, which have
// no snapshot, so we can't do any better
Session.RemoveCollection(persister, Key);
//processArrayOrNewCollection(collection, type);
}
return null;
}