@@ -317,19 +317,24 @@ session.Flush();]]></programlisting>
317
317
<programlisting ><![CDATA[ public class Persistent
318
318
{
319
319
private bool _saved = false;
320
-
320
+
321
321
public void OnSave()
322
322
{
323
- _saved= true;
323
+ _saved = true;
324
324
}
325
-
325
+
326
326
public void OnLoad()
327
327
{
328
- _saved= true;
328
+ _saved = true;
329
329
}
330
-
330
+
331
+ public void OnDelete()
332
+ {
333
+ _saved = false;
334
+ }
335
+
331
336
......
332
-
337
+
333
338
public bool IsSaved
334
339
{
335
340
get { return _saved; }
@@ -338,8 +343,8 @@ session.Flush();]]></programlisting>
338
343
339
344
<para >
340
345
(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.
343
348
</para >
344
349
345
350
<programlisting ><![CDATA[ public object IsTransient(object entity)
@@ -354,7 +359,7 @@ session.Flush();]]></programlisting>
354
359
}
355
360
}
356
361
357
- public bool OnLoad(object entity,
362
+ public bool OnLoad(object entity,
358
363
object id,
359
364
object[] state,
360
365
string[] propertyNames,
@@ -372,8 +377,17 @@ public boolean OnSave(object entity,
372
377
{
373
378
if (entity is Persistent) ( (Persistent) entity ).OnSave();
374
379
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();
375
389
}]]> </programlisting >
376
-
390
+
377
391
</sect1 >
378
392
379
393
<sect1 id =" example-parentchild-conclusion" >
0 commit comments