Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 864d1c3c3cd8df4e3a2692faf8776e05 > files > 1252

db4o-doc-7.4-2.fc13.i686.rpm

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Calling constructors</title>
    <link rel="stylesheet" type="text/css" href="../../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Calling constructors</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>



<span name="cs_wiki_filter" csw_filters="net">
<p>.NET: </p><p><code>Db4oFactory.Configure().CallConstructors(true)</code></p>
</span>
<a name="Advantage"></a><h2>Advantage</h2>
<p>
will configure db4o to use constructors to instantiate objects.</p>
<a name="Effect"></a><h2>Effect</h2>
<p>
On VMs where this is supported (Sun Java VM &gt; 1.4, .NET, Mono) db4o tries to create instances of objects without calling a constructor. On Java VMs db4o is using reflection for this feature so this may be considerably slower than using a constructor. For the best performance on Java it is recommended to add a public zero-parameter constructor to every persistent class and to turn constructors on. Benchmarks on .NET have shown that the default setting ( #callConstructors(false) ) is faster.</p>

<a name="Alternate Strategies"></a><h2>Alternate Strategies</h2>
<p>
Constructors can also be turned on for individual classes only with</p>



<span name="cs_wiki_filter" csw_filters="net">
<p>.NET: <code>Db4oFactory.Configure().ObjectClass(typeof(Foo)).CallConstructor(true)</code></p>
</span>
<p>There are some classes (e.g. java.util.Calendar) that require a constructor to be called to work. Further details can be found in the <a href="../../object_lifecycle/object_construction.html" class="wikiLink">Constructors</a>  chapter</p></div>
    </div>
    <div id="footer">
					This revision (13) was last Modified 2007-08-04T11:34:14 by Tetyana.
				</div>
  </body>
</html>