1. First GlanceBefore diving straight into the first source code samples let's get you familiar with some basics.1.1. The db4o engine...The db4o object database engine consists of one single DLL. This is all that you need to program against. The version supplied with the distribution can be found in /usr/lib/db4o/.1.2. InstallationTo use db4o in a development project, you only need to add one of the above db4o.dll files to your project references.Here is how to do this if you are using MonoDevelop: - Right-click on "References" in the Solution Tab - choose "Edit References" - select the ".NET Assembly" tab and then "Browse" - select /usr/lib/db4o/db4o.dll - click "Open" - click "OK" 1.3. Object Manager1.3.1. InstallationThe db4o Object Manager, a GUI tool to browse and query database files, is packaged separately for each supported platform. Choose from the following links in the db4o Download Center for your platform:- db4o ObjectManager for Windows IKVM (Java VM included) - db4o ObjectManager for Windows no Java VM - db4o ObjectManager for Linux Once you have downloaded the appropriate Object Manager build, create a folder called Object Manager in an appropriate location and unpack the downloaded zip file there. 1.3.2. Running1.3.2.1. Windows IKVMObject Manager for Windows IKVM includes the open-source IKVM Java virtual machine in the download. Simply double-click the objectmanager.bat file to start Object Manager.1.3.2.2. Windows no Java VMThis build assumes that your computer already has a Sun Java Virtual Machine version 1.3 or later installed and that your operating system path already lists the directory containing your java.exe file. If this is true, you can simply double-click the objectmanager.bat file to start Object Manager. Otherwise, you will need to edit objectmanager.bat and specify the full path and file name for your java.exe file on the first line.1.3.2.3. LinuxThis build assumes that your computer already has a Sun Java Virtual Machine version 1.3 or later installed and that your PATH variable already lists the directory containing the java binary. If this is not the case, you willneed to edit the objectmanager.sh file and specify the full path and file name of the Java binary on the "export VMEXE" line". Since the zip archive does not preserve the executable permissions for objectmanager.sh, you will need to `chmod +x objectmanager.sh`. Once this is complete, running objectmanager.sh will start Object Manager. 1.4. APIThe API documentation for db4o is supplied as a set of HTML pages in/usr/share/doc/packages/db4o/api/index.html. While you read through this tutorial, it may be helpful to look into the API documentation occasionaly. For the start, the namespaces com.db4o and com.db4o.query are all that you need to worry about. Let's take a first brief look at one of the most important interfaces:
This will be your view of a db4o database: - An ObjectContainer can either be a database in single-user mode or a client to a db4o server. - Every ObjectContainer owns one transaction. All work is transactional. When you open an ObjectContainer, you are in a transaction, when you commit() or rollback(), the next transaction is started immediately. - Every ObjectContainer maintains it's own references to stored and instantiated objects. In doing so, it manages object identities. In case you wonder why you only see very few methods in an ObjectContainer, here is why: The db4o interface is supplied in two steps in two namespaces, com.db4o and com.db4o.ext for the following reasons: - It's easier to get started, because the important methods are emphasized. - It will be easier for other products to copy the basic db4o interface. - We hint how a very-light-version of db4o should look like. Every com.db4o.ObjectContainer object also always is a com.db4o.ext.ExtObjectContainer. You can cast to ExtObjectContainer or you can call the #ext() method if you want to use advanced features. -- generated by Doctor courtesy of db4objects Inc. |