Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 2e9c43658e374d290a2de15d25134ac8 > files > 1743

db4o-doc-8.0-1.fc15.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="docs.css">
<!--[if gte IE 5]>
     <link href="docs_ie.css" rel="stylesheet" type="text/css">
<![endif]-->
</head>
<body><div id="pagecontainer"><table><tr><td width="5">&nbsp;</td><td><a name="IDs"></a><br>
<a name="outline229"></a><br><h1>16. IDs</h1><br>
The db4o team recommends, not to use object IDs where this is&nbsp;not necessary. db4o keeps track of object identities in a&nbsp;transparent way, by identifying "known" objects on updates.&nbsp;The reference system also makes sure that every persistent&nbsp;object is instantiated only once, when a graph of objects is&nbsp;retrieved from the database, no matter which access path is&nbsp;chosen. If an object is accessed by multiple queries or by&nbsp;multiple navigation access paths, db4o will always return&nbsp;the one single object, helping you to put your object graph together&nbsp;exactly the same way as it was when it was stored, without&nbsp;having to use IDs.<br>
<br>
The use of IDs does make sense when object and database are&nbsp;disconnected, for instance in stateless applications.<br>
<br>
db4o provides two types of ID systems.<br>
<br>
<ul>
<a name="outline230"></a><br><h2>16.1. Internal IDs</h2>The internal db4o ID is a physical pointer into the database&nbsp;with only one indirection in the file to the actual object&nbsp;so it is the fastest external access to an object db4o provides.&nbsp;The internal ID of an object is available with<br>
<table width="100%" cellpadding="3" cellspacing="0" border="0"><tr><td class="lg">
<code>objectContainer.Ext().GetID(object);</code></td></tr></table>
<br>
To get an object for an internal ID use<br>
<table width="100%" cellpadding="3" cellspacing="0" border="0"><tr><td class="lg">
<code>objectContainer.Ext().GetByID(id);</code></td></tr></table>
<br>
Note that #GetByID() does not activate objects. If you want&nbsp;to work with objects that you get with #GetByID(), your code&nbsp;would have to make sure the object is <a href="Deep.html#Activation">activated</a>&nbsp;by calling<br>
<table width="100%" cellpadding="3" cellspacing="0" border="0"><tr><td class="lg">
<code>objectContainer.Activate(object, depth);</code></td></tr></table>
<br>
db4o assigns internal IDs to any stored first class object. These&nbsp;internal IDs are guaranteed to be unique within one IObjectContainer/IObjectServer&nbsp;and they will stay the same for every&nbsp;object when an IObjectContainer/IObjectServer is closed and reopened.&nbsp;Internal IDs <b>will change</b>&nbsp;when an object is moved from one&nbsp;IObjectContainer to another, as it happens during Defragment.<br>
<br>
<a name="outline231"></a><br><h2>16.2. Unique Universal IDs (UUIDs)</h2>For long term external references and to identify an object even&nbsp;after it has been copied or moved to another IObjectContainer, db4o&nbsp;supplies UUIDs. These UUIDs are not generated by default, since&nbsp;they occupy some space and consume some performance for maintaining&nbsp;their index. UUIDs can be turned on globally or for individual classes:<br>
<table width="100%" cellpadding="3" cellspacing="0" border="0"><tr><td class="lg">
<code>IFileConfiguration#GenerateUUIDs(Int32.MaxValue); <br>
Db4oFactory.Configure().ObjectClass(typeof(Foo)).GenerateUUIDs(true);</code></td></tr></table>
<br>
The respective methods for working with UUIDs are:<br>
<table width="100%" cellpadding="3" cellspacing="0" border="0"><tr><td class="lg">
<code>IExtObjectContainer#GetObjectInfo(object) <br>
IObjectInfo#GetUUID();<br>
IExtObjectContainer#GetByUUID(Db4oUUID);</code></td></tr></table>
<br>
<br><br><div id="footer"><p align="center">Do you have any questions, suggestions or feedback? Ask your questions in the <a href="http://developer.db4o.com/Forums.aspx" target=_top>db4o forums</a>. Join the <a href="http://developer.db4o.com" target=_top>db4o community</a> for addional resources and news.<br><br><a href="http://www.db4o.com/" target=_top><small>www.db4o.com</small></a></p>.</div><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></td></tr></table></div></body></html>