Welcome. db4o is the native Java,.NET and Mono open source object database. This tutorial was written to get you started with db4o as quickly as possible. This documentation and tutorial is intended to get you started with db4o and to be a reliable The db4o object database engine consists of one single jar file. Introduction; Query by Example; Updates and identity; A search utility method; Advanced queries; Native queries in db4o; In conclusion.

Author: Kigall Voodooktilar
Country: Equatorial Guinea
Language: English (Spanish)
Genre: Technology
Published (Last): 22 July 2008
Pages: 259
PDF File Size: 2.18 Mb
ePub File Size: 15.21 Mb
ISBN: 234-6-58366-260-1
Downloads: 63978
Price: Free* [*Free Regsitration Required]
Uploader: Dilabar

Using tables to store objects is like driving your car home and then disassembling it to put it into the garage.

As explained in the section on Dealing with Object Activation, the ActivationDepth controls how much data is loaded when an object is retrieved from the database. SODA query expressions are a standard that was present in all but the earliest versions of db4o. For strings, matches will end with the supplied value. It’s important to know that db4o works best if you open the database file when you start working with data, and close the db when all posible operations are completed.

db4o tutorial

Setting the ActivationDepth to int. Combine with Smaller and Greater to include the specified value.

The db4o interface is supplied in two steps in two java packages, com. By default, db4o will NOT descend into child objects. In this second article in The busy Java developer’s guide to db4oI tytorial the OODBMS notion of identity as a launching point for explaining how db4o stores and retrieves objects, as well as introducing its native query facility.


Notice that this class does not contain any db4o-related code. Best for limited resource environments. You need it to compile the examples. While you read through thistutorial it may be helpful to look into the API documentation occasionaly. tutoriaal

Getting Started With db4o

There is one more thing to be aware of: When dealing with objects that may have relations to other objects quite deep think of the tutoriaal of data from Customer to Order to OrderItem to Product with relations to Address objects for billing and shipping and then PO and payment transactions it would be quite expensive to have to pull all of that data into memory from the DB if all you wanted was the Customer object. UpdateDepth [depth] ; The default value 1 means db4o will not descend into child objects when updating stored object instances.

Setting the UpdateDepth to 0 will prevent any changes from being saved to the database. When using Query-By-Example, you create a prototypical object for db4o to use as an example of what you wish to retrieve.

The busy Java developer’s guide to db4o: Queries, updates, and identity

For example, it is entirely possible to write a native query complex enough to defeat the bytecode analyzer, thus requiring the worst-case execution model to take place. So QBE can be used only to retrieve exact-value matches. First Steps Let’s get started as simple as possible. Because db4o uses the native tuforial or referential identity, it’s better to open the database or connection when your application begins, do all your work, then close the database when your program is shutting down.

The drawback of OQL is that it wants to return You can then call the Activate object, depth method to manually activate the object as described above.


Two objects of note are com. QBE lets you pass db4o an example object. Over a million developers have joined DZone.

db4o tutorial – db4objects Inc. – Informatique

For strings, matches will start with the supplied value. Matching values will NOT equal the supplied value. It will not undo changes to any currently loaded objects.

Note that there is a more efficient way to perform this style of query against the underlying objects stored on disk using gutorial db4o SODA query API, but it’s slightly out of scope for this article, so I’ll leave it for a later discussion.

OpenFile [filename] ; While a db4o database file is open, it is locked and cannot be accessed by another application at the same time. If the bytecode is easy enough to understand, db4o will turn that query into a SODA query for efficiency, in which case there is no need to instantiate all the objects to pass into the match method.

You can’t really anticipate variations of this type although you can learn about them by experienceso it’s always a good idea to Let The System Tell You, as they say in extreme programming. Java security settings have to allow applets to be run. This content tuyorial part of the series: