<html> <head> <META http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Persistent and transient fields</title> <link rel="stylesheet" type="text/css" href="../../../style.css"> </head> <body> <div class="CommonContent"> <div class="CommonContentArea"> <h1>Persistent and transient fields</h1><div id="TOC"><div id="TOCinner"><span class="TOCtitle">Contents</span><div class="TOCcontents"><ul><li><a href ="#Advantage">Advantage</a></li><li><a href ="#Effect">Effect</a></li><li><a href ="#Alternate strategies">Alternate strategies</a></li></ul></li></ul></div></div></div> <p>Do not create fields that you don't need for persistence</p> <a name="Advantage"></a><h2>Advantage</h2> <p>Storing only needed information will help to keep your database footprint as small as possible.</p> <a name="Effect"></a><h2>Effect</h2> <p>If your persistent class contains fields that do not need to be stored you should mark them as transient to prevent them from being stored:</p> <span name="cs_wiki_filter" csw_filters="net"> <p>.NET:<br><code>public class NotStorable {<br> [Transient] private int length;<br>. . . <br>}</code></p> </span> <p>You can use <a href="../../implementation_strategies/callbacks.html" class="wikiLink">Callbacks</a> or <a href="../../implementation_strategies/translators.html" class="wikiLink">Translators</a> to set transient fields on retrieval.</p> <p>Also avoid storing classes having only transient information - their indexes' maintenance will produce unnecessary performance overhead.</p> <a name="Alternate strategies"></a><h2>Alternate strategies</h2> <p>In some cases you may want to persist class meta-information without the actual object data. The example can be database singleton for <a href="../../client-server/remote_code_execution.html" class="wikiLink">remote code execution</a></p></div> </div> <div id="footer"> This revision (9) was last Modified 2007-05-07T16:29:51 by Tetyana. </div> </body> </html>