Skip to content

Commit babbdb6

Browse files
Fix #823 - OnDelete should set IsSaved to false
1 parent 2922e40 commit babbdb6

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

doc/reference/modules/example_parentchild.xml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -317,19 +317,24 @@ session.Flush();]]></programlisting>
317317
<programlisting><![CDATA[public class Persistent
318318
{
319319
private bool _saved = false;
320-
320+
321321
public void OnSave()
322322
{
323-
_saved=true;
323+
_saved = true;
324324
}
325-
325+
326326
public void OnLoad()
327327
{
328-
_saved=true;
328+
_saved = true;
329329
}
330-
330+
331+
public void OnDelete()
332+
{
333+
_saved = false;
334+
}
335+
331336
......
332-
337+
333338
public bool IsSaved
334339
{
335340
get { return _saved; }
@@ -338,8 +343,8 @@ session.Flush();]]></programlisting>
338343

339344
<para>
340345
(The <literal>saved</literal> property is non-persistent.)
341-
Now implement <literal>IsTransient()</literal>, along with <literal>OnLoad()</literal>
342-
and <literal>OnSave()</literal> as follows.
346+
Now implement <literal>IsTransient()</literal>, along with <literal>OnLoad()</literal>,
347+
<literal>OnSave()</literal> and <literal>OnDelete()</literal> as follows.
343348
</para>
344349

345350
<programlisting><![CDATA[public object IsTransient(object entity)
@@ -354,7 +359,7 @@ session.Flush();]]></programlisting>
354359
}
355360
}
356361
357-
public bool OnLoad(object entity,
362+
public bool OnLoad(object entity,
358363
object id,
359364
object[] state,
360365
string[] propertyNames,
@@ -372,8 +377,17 @@ public boolean OnSave(object entity,
372377
{
373378
if (entity is Persistent) ( (Persistent) entity ).OnSave();
374379
return false;
380+
}
381+
382+
public virtual void OnDelete(object entity,
383+
object id,
384+
object[] state,
385+
string[] propertyNames,
386+
IType[] types)
387+
{
388+
if (entity is Persistent) ( (Persistent) entity ).OnDelete();
375389
}]]></programlisting>
376-
390+
377391
</sect1>
378392

379393
<sect1 id="example-parentchild-conclusion">

0 commit comments

Comments
 (0)