/// <summary> /// Cascade to the collection elements /// </summary> /// <param name="action"></param> /// <param name="style"></param> /// <param name="collectionType"></param> /// <param name="elemType"></param> /// <param name="child"></param> /// <param name="cascadeVia"></param> /// <param name="session"></param> /// <param name="anything"></param> private static void CascadeCollection( CascadingAction action, CascadeStyle style, PersistentCollectionType collectionType, IType elemType, object child, CascadePoint cascadeVia, ISessionImplementor session, object anything) { // cascade to current collection elements if (log.IsDebugEnabled) { log.Debug("cascading to collection: " + collectionType.Role); } ICollection iter = action.CascadableChildrenCollection(collectionType, child); foreach (object obj in iter) { Cascade(session, obj, elemType, action, style, cascadeVia, anything); } // handle oprhaned entities!! if (style.HasOrphanDelete && action.DeleteOrphans() && child is PersistentCollection) { // We can do the cast since orphan-delete does not apply to: // 1. newly instatiated collections // 2. arrays ( we can't track orphans for detached arrays) DeleteOrphans(child as PersistentCollection, session); } }
public override bool DoCascade(CascadingAction action) { return(action == CascadingAction.ActionSaveUpdate || action == CascadingAction.ActionLock || action == CascadingAction.ActionReplicate || action == CascadingAction.ActionCopy); }
/// <summary> /// Check sub elements-nullability. Returns property path that break /// nullability or null if none /// </summary> /// <param name="propertyType">type to check </param> /// <param name="value">value to check </param> /// <returns> property path </returns> private string CheckSubElementsNullability(IType propertyType, object value) { //for non null args, check for components and elements containing components if (propertyType.IsComponentType) { return(CheckComponentNullability(value, (IAbstractComponentType)propertyType)); } else if (propertyType.IsCollectionType) { //persistent collections may have components CollectionType collectionType = (CollectionType)propertyType; IType collectionElementType = collectionType.GetElementType(session.Factory); if (collectionElementType.IsComponentType) { //check for all components values in the collection IAbstractComponentType componentType = (IAbstractComponentType)collectionElementType; IEnumerable ec = CascadingAction.GetLoadedElementsIterator(session, collectionType, value); foreach (object compValue in ec) { if (compValue != null) { return(CheckComponentNullability(compValue, componentType)); } } } } return(null); }
/// <summary> /// Cascade an action to the child or children /// </summary> /// <param name="session"></param> /// <param name="child"></param> /// <param name="type"></param> /// <param name="action"></param> /// <param name="style"></param> /// <param name="cascadeTo"></param> /// <param name="anything"></param> private static void Cascade( ISessionImplementor session, object child, IType type, CascadingAction action, CascadeStyle style, CascadePoint cascadeTo, object anything) { if (child != null) { if (type.IsAssociationType) { if ((( IAssociationType )type).ForeignKeyType.CascadeNow(cascadeTo)) { if (type.IsEntityType || type.IsObjectType) { action.Cascade(session, child, anything); } else if (type.IsPersistentCollectionType) { CascadePoint cascadeVia; if (cascadeTo == CascadePoint.CascadeAfterInsertBeforeDelete) { cascadeVia = CascadePoint.CascadeAfterInsertBeforeDeleteViaCollection; } else { cascadeVia = cascadeTo; } PersistentCollectionType pctype = ( PersistentCollectionType )type; ICollectionPersister persister = session.Factory.GetCollectionPersister(pctype.Role); IType elemType = persister.ElementType; // cascade to current collection elements if (elemType.IsEntityType || elemType.IsObjectType || elemType.IsComponentType) { CascadeCollection(action, style, pctype, elemType, child, cascadeVia, session, anything); } } } } else if (type.IsComponentType) { IAbstractComponentType ctype = (( IAbstractComponentType )type); object[] children = ctype.GetPropertyValues(child, session); IType[] types = ctype.Subtypes; for (int i = 0; i < types.Length; i++) { CascadeStyle componentPropertyStyle = ctype.Cascade(i); if (componentPropertyStyle.DoCascade(action)) { Cascade(session, children[i], types[i], action, componentPropertyStyle, cascadeTo, anything); } } } } }
public CascadeEntityLoader(IOuterJoinLoadable persister, CascadingAction action, ISessionFactoryImplementor factory) : base(persister, persister.IdentifierType, factory, new CollectionHelper.EmptyMapClass<string, IFilter>()) { JoinWalker walker = new CascadeEntityJoinWalker(persister, action, factory); InitFromWalker(walker); PostInstantiate(); log.Debug(string.Format("Static select for action {0} on entity {1}: {2}", action, entityName, SqlString)); }
public CascadeEntityJoinWalker(IOuterJoinLoadable persister, CascadingAction action, ISessionFactoryImplementor factory) : base(persister, factory, new CollectionHelper.EmptyMapClass<string, IFilter>()) { cascadeAction = action; SqlStringBuilder whereCondition = WhereString(Alias, persister.IdentifierColumnNames, 1) //include the discriminator and class-level where, but not filters .Add(persister.FilterFragment(Alias, new CollectionHelper.EmptyMapClass<string, IFilter>())); InitAll(whereCondition.ToSqlString(), SqlString.Empty, LockMode.Read); }
public override bool ReallyDoCascade(CascadingAction action) { for (int i = 0; i < styles.Length; i++) { if (styles[i].ReallyDoCascade(action)) { return(true); } } return(false); }
public override bool DoCascade(CascadingAction action) { return action == CascadingAction.Evict; }
/// <summary> /// Probably more aptly named something like doCascadeToCollectionElements(); /// it is however used from both the collection and to-one logic branches... /// </summary> /// <param name="action">The action to be checked for cascade-ability. </param> /// <returns> True if the action should be really cascaded under this style; false otherwise. </returns> /// <remarks> /// For this style, should the given action really be cascaded? The default /// implementation is simply to return {@link #doCascade}; for certain /// styles (currently only delete-orphan), however, we need to be able to /// control this separately. /// </remarks> public virtual bool ReallyDoCascade(CascadingAction action) { return(DoCascade(action)); }
public override bool ReallyDoCascade(CascadingAction action) { for (int i = 0; i < styles.Length; i++) { if (styles[i].ReallyDoCascade(action)) return true; } return false; }
public override bool DoCascade(CascadingAction action) { return action == CascadingAction.Merge || action == CascadingAction.SaveUpdateCopy; }
/// <summary> /// Cascade an action from the parent object to all its children. /// </summary> /// <param name="session"></param> /// <param name="persister"></param> /// <param name="parent"></param> /// <param name="action"></param> /// <param name="cascadeTo"></param> /// <param name="anything"></param> public static void Cascade(ISessionImplementor session, IClassPersister persister, object parent, CascadingAction action, CascadePoint cascadeTo, object anything) { if (persister.HasCascades) { if (log.IsDebugEnabled) { log.Debug("processing cascades for: " + persister.ClassName); } IType[] types = persister.PropertyTypes; CascadeStyle[] cascadeStyles = persister.PropertyCascadeStyles; for (int i = 0; i < types.Length; i++) { CascadeStyle style = cascadeStyles[i]; if (style.DoCascade(action)) { Cascade(session, persister.GetPropertyValue(parent, i), types[i], action, style, cascadeTo, anything); } } if (log.IsDebugEnabled) { log.Debug("done processing cascades for: " + persister.ClassName); } } }
/// <summary> /// /// </summary> /// <param name="session"></param> /// <param name="persister"></param> /// <param name="parent"></param> /// <param name="action"></param> /// <param name="cascadeTo"></param> public static void Cascade(ISessionImplementor session, IClassPersister persister, object parent, CascadingAction action, CascadePoint cascadeTo) { Cascade(session, persister, parent, action, cascadeTo, null); }
public override bool DoCascade(CascadingAction action) { return(action == CascadingAction.ActionDelete); }
public override bool DoCascade(CascadingAction action) { return action == CascadingAction.Merge; }
public Cascade(CascadingAction action, CascadePoint point, IEventSource eventSource) { this.point = point; this.eventSource = eventSource; this.action = action; }
public override bool DoCascade(CascadingAction action) { return action == CascadingAction.Delete || action == CascadingAction.SaveUpdate; }
public override bool DoCascade(CascadingAction action) { return action == CascadingAction.ActionSaveUpdate || action == CascadingAction.ActionLock || action == CascadingAction.ActionReplicate || action == CascadingAction.ActionCopy; }
/// <summary> /// Probably more aptly named something like doCascadeToCollectionElements(); /// it is however used from both the collection and to-one logic branches... /// </summary> /// <param name="action">The action to be checked for cascade-ability. </param> /// <returns> True if the action should be really cascaded under this style; false otherwise. </returns> /// <remarks> /// For this style, should the given action really be cascaded? The default /// implementation is simply to return {@link #doCascade}; for certain /// styles (currently only delete-orphan), however, we need to be able to /// control this separately. /// </remarks> public virtual bool ReallyDoCascade(CascadingAction action) { return DoCascade(action); }
public override bool DoCascade(CascadingAction action) { return action == CascadingAction.ActionDelete; }
public override bool ReallyDoCascade(CascadingAction action) { return(action == CascadingAction.Delete); }
/// <summary> /// Cascade an action to the child or children /// </summary> /// <param name="session"></param> /// <param name="child"></param> /// <param name="type"></param> /// <param name="action"></param> /// <param name="style"></param> /// <param name="cascadeTo"></param> /// <param name="anything"></param> private static void Cascade( ISessionImplementor session, object child, IType type, CascadingAction action, CascadeStyle style, CascadePoint cascadeTo, object anything) { if (child != null) { if (type.IsAssociationType) { if (((IAssociationType) type).ForeignKeyDirection.CascadeNow(cascadeTo)) { if (type.IsEntityType || type.IsAnyType) { action.Cascade(session, child, anything); } else if (type.IsCollectionType) { CascadePoint cascadeVia; if (cascadeTo == CascadePoint.CascadeAfterInsertBeforeDelete) { cascadeVia = CascadePoint.CascadeAfterInsertBeforeDeleteViaCollection; } else { cascadeVia = cascadeTo; } CollectionType pctype = (CollectionType) type; ICollectionPersister persister = session.Factory.GetCollectionPersister(pctype.Role); IType elemType = persister.ElementType; // cascade to current collection elements if (elemType.IsEntityType || elemType.IsAnyType || elemType.IsComponentType) { CascadeCollection(action, style, pctype, elemType, child, cascadeVia, session, anything); } } } } else if (type.IsComponentType) { IAbstractComponentType ctype = ((IAbstractComponentType) type); object[] children = ctype.GetPropertyValues(child, session); IType[] types = ctype.Subtypes; for (int i = 0; i < types.Length; i++) { CascadeStyle componentPropertyStyle = ctype.GetCascadeStyle(i); if (componentPropertyStyle.DoCascade(action)) { Cascade(session, children[i], types[i], action, componentPropertyStyle, cascadeTo, anything); } } } } }
/// <summary> For this style, should the given action be cascaded? </summary> /// <param name="action">The action to be checked for cascade-ability. </param> /// <returns> True if the action should be cascaded under this style; false otherwise. </returns> public abstract bool DoCascade(CascadingAction action);
/// <summary> /// /// </summary> /// <param name="session"></param> /// <param name="persister"></param> /// <param name="parent"></param> /// <param name="action"></param> /// <param name="cascadeTo"></param> public static void Cascade(ISessionImplementor session, IEntityPersister persister, object parent, CascadingAction action, CascadePoint cascadeTo) { Cascade(session, persister, parent, action, cascadeTo, null); }
public override bool DoCascade(CascadingAction action) { return(true); }
/// <summary> /// Cascade an action from the parent object to all its children. /// </summary> /// <param name="session"></param> /// <param name="persister"></param> /// <param name="parent"></param> /// <param name="action"></param> /// <param name="cascadeTo"></param> /// <param name="anything"></param> public static void Cascade(ISessionImplementor session, IEntityPersister persister, object parent, CascadingAction action, CascadePoint cascadeTo, object anything) { if (persister.HasCascades) { if (log.IsDebugEnabled) { log.Debug("processing cascades for: " + persister.ClassName); } IType[] types = persister.PropertyTypes; CascadeStyle[] cascadeStyles = persister.PropertyCascadeStyles; for (int i = 0; i < types.Length; i++) { CascadeStyle style = cascadeStyles[i]; if (style.DoCascade(action)) { Cascade(session, persister.GetPropertyValue(parent, i), types[i], action, style, cascadeTo, anything); } } if (log.IsDebugEnabled) { log.Debug("done processing cascades for: " + persister.ClassName); } } }
/// <summary> /// Cascade to the collection elements /// </summary> /// <param name="action"></param> /// <param name="style"></param> /// <param name="collectionType"></param> /// <param name="elemType"></param> /// <param name="child"></param> /// <param name="cascadeVia"></param> /// <param name="session"></param> /// <param name="anything"></param> private static void CascadeCollection( CascadingAction action, CascadeStyle style, CollectionType collectionType, IType elemType, object child, CascadePoint cascadeVia, ISessionImplementor session, object anything) { // cascade to current collection elements if (log.IsDebugEnabled) { log.Debug("cascading to collection: " + collectionType.Role); } ICollection iter = action.CascadableChildrenCollection(collectionType, child); foreach (object obj in iter) { Cascade(session, obj, elemType, action, style, cascadeVia, anything); } // handle oprhaned entities!! if (style.HasOrphanDelete && action.DeleteOrphans() && child is IPersistentCollection) { // We can do the cast since orphan-delete does not apply to: // 1. newly instatiated collections // 2. arrays ( we can't track orphans for detached arrays) System.Type entityName = collectionType.GetAssociatedClass(session.Factory); DeleteOrphans(entityName, child as IPersistentCollection, session); } }
public override bool DoCascade(CascadingAction action) { return action == CascadingAction.Refresh; }
public override bool DoCascade(CascadingAction action) { return(action == CascadingAction.Refresh); }
public override bool DoCascade(CascadingAction action) { return action == CascadingAction.Replicate; }
public override bool DoCascade(CascadingAction action) { return(action == CascadingAction.Replicate); }
public override bool DoCascade(CascadingAction action) { return action == CascadingAction.Persist || action == CascadingAction.PersistOnFlush; }
public override bool DoCascade(CascadingAction action) { return(action == CascadingAction.Merge); }
public override bool ReallyDoCascade(CascadingAction action) { return action == CascadingAction.Delete; }
public override bool DoCascade(CascadingAction action) { return(action == CascadingAction.Persist || action == CascadingAction.PersistOnFlush); }
public override bool DoCascade(CascadingAction action) { return(action == CascadingAction.Delete || action == CascadingAction.SaveUpdate); }
public override bool DoCascade(CascadingAction action) { return true; }
public override bool DoCascade(CascadingAction action) { return(action == CascadingAction.Merge || action == CascadingAction.SaveUpdateCopy); }