I´ve tested a few things out and came up with this:
class A {
[PrimaryKey("A_ID")]
public int Id { get; set; }
[HasMany(Inverse=false,
Cascade=ManyRelationCascadeEnum.AllDeleteOrphan)]
public IList<B> BList { get; set; }
}
class B {
[PrimaryKey("B_ID")]
public int Id { get; set; }
[BelongsTo("A_ID")]
public A Aref { get; set; }
}
now I don´t get the error from Oracle and the A object is actually
deleted. Unfortunately all B children are not deleted and the Aref
field is set to null at the database, so I end up with a lot of
orphans.
I don´t know what else to do, any thoughts?
On 9 fev, 16:32, Joao Carlos <[email protected]> wrote:
> Hello,
>
> I´ve been trying to use cascade delete, but, for some reason, it is
> not working ;/
> I checked most of the cascade delete topics but nothing seems to work
> for me, so, any help is appreciated.
>
> Here´s a prototype of what I have:
>
> [code]
> class A {
> [PrimaryKey("A_ID")]
> public int Id { get; set; }
>
> [HasMany(Inverse=true,
> Cascade=ManyRelationCascadeEnum.AllDeleteOrphan)]
> public IList<B> BList { get; set; }}
>
> [/code]
>
> [code]
> class B {
> [PrimaryKey("B_ID")]
> public int Id { get; set; }
>
> [BelongsTo("A_ID")]
> public A AId { get; set; }
>
> [HasMany(Inverse=true,
> Cascade=ManyRelationCascadeEnum.AllDeleteOrphan)]
> public IList<C> CList { get; set; }}
>
> [/code]
>
> [code]
> class C {
> [PrimaryKey("C_ID")]
> public int Id { get; set; }
>
> [BelongsTo("B_ID")]
> public B BId { get; set; }}
>
> [/code]
>
> and this is the error I get:
> [code]
> [OracleException (0x80131938): ORA-02292: integrity constraint
> (PROJECTNAME.FK929B9C00F122688D) violated - child record found
> ]
> System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle
> errorHandle, Int32 rc) +166
> System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle
> statementHandle, CommandBehavior behavior, Boolean needRowid,
> OciRowidDescriptor& rowidDescriptor, ArrayList&
> resultParameterOrdinals) +1719
>
> System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean
> needRowid, OciRowidDescriptor& rowidDescriptor) +503
> System.Data.OracleClient.OracleCommand.ExecuteNonQuery() +140
> NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd)
> +261
> NHibernate.AdoNet.NonBatchingBatcher.AddToBatch(IExpectation
> expectation) +49
> NHibernate.Persister.Entity.AbstractEntityPersister.Delete(Object
> id, Object version, Int32 j, Object obj, SqlCommandInfo sql,
> ISessionImplementor session, Object[] loadedState) +1277
>
> [GenericADOException: could not delete: [A#90][SQL: DELETE FROM A
> WHERE A_ID = ?]]
> AA.Delete() in AA:152
> AA.Process() in AA.cs:105
> AList.GridView1_RowDeleting(Object sender, GridViewDeleteEventArgs
> e) in AList.aspx.cs:39
>
> System.Web.UI.WebControls.GridView.OnRowDeleting(GridViewDeleteEventArgs
> e) +133
> System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row,
> Int32 rowIndex) +604
> System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean
> causesValidation, String validationGroup) +1134
> System.Web.UI.WebControls.GridView.RaisePostBackEvent(String
> eventArgument) +199
>
> System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.Rais
> ePostBackEvent(String
> eventArgument) +7
> System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument) +11
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
> +177
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
> +1746
> [/code]
>
> Can anyone help?
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.