objectContainer.ext().getID(object);
objectContainer.ext().getByID(id);
objectContainer.activate(object, depth);
Db4o.configure().generateUUIDs(Integer.MAX_VALUE); <br /> Db4o.configure().objectClass(typeof(Foo)).generateUUIDs(true);
ExtObjectContainer#getObjectInfo(Object) <br /> ObjectInfo#getUUID();<br /> ExtObjectContainer#getByUUID(Db4oUUID);
mrshrinkray:If I have 2 companies with the same name, it updates them both. The obvious solution is to add an ID field which is randomly generated integer.
Another way of identifying the Object is UUID , provieded by db4o.
For more explanation about UUID please read chapter 15 in the tutorial.
Also please see the Carl explanation for getting the UUID in the object itself. Based on UUID you can differentiate the objects.
http://developer.db4o.com/forums/thread/21897.aspx
Regards
Vinayak
mrshrinkray:This is a .NET website application, so it would be quite memory-intensive to pass the object(s) in the viewstate in order to avoid using IDs.
In .NET, Use the ObjectDataSource. Handle the ObjectOnCreating event.
Dino Esposito (on the ASP.NET team) had a great blog entry about how to use the ObjectDataSource properly: http://weblogs.asp.net/despos/archive/2006/04/27/444188.aspx
The key is to pass only the ID (or db4o UUID) of the desired object(s). Then to use the ObjectDataSource events to properly retrieve a working copy of the object (in db4o, this object would still be in memory in the weak-reference cache, so retrieval is almost nothing) and to store it again (a single line, using db4o).
Eric Falsken: Then to use the ObjectDataSource events to properly retrieve a working copy of the object
Then to use the ObjectDataSource events to properly retrieve a working copy of the object
Calling Bind() will cause any other instance of the object in memory to be unbound. So if another thread is working with the same object from the same objectContainer, you will break the binding.
Calling GetByID(long) is also quite a bit faster than deserializing. And it dosn't cut down on any code. You store the ID to ViewState/ControlState and you have a property getter to retrieve your desired object. If you use the ObjectDataSource, then you don't even have to do your field-to-property mapping. If you roll-your-own via serializing your object to viewstate, then you have to do your own field-to-property mapping in addition to making sure that your object is safely serializable. A hell of a lot of work. Not to mention the MUCH reduced size of the ViewState.
ObjectDataSource works VERY well and will speed up your development and run faster. And don't forget about Atlas!