Questions tagged [db4o]

db4o is an open source embeddable object database for Java and .NET.

As of October 2014 Versant has discontinued the work on db4o due to a decision by Actian, which is the new owner of Versant.

db4o is an simple to use yet powerful object database. It is designed for embedded scenarios and runs on the Java and .NET platform.

You just drop db4o's single programming library (.jar /.dll) into your development environment, open a database file and store any object - no matter how complex - with just one line of code, e.g., in Java:

public void store(Car car) {
  ObjectContainer db = Db4oEmbedded.openFile("car.yap");
  db.store(car);
  db.close();
}

This unmatched ease-of-use results in drastically reduced development time.

Rather than using string-based APIs (such as SQL, OQL, JDOQL, JPAQL, and SODA), Native Queries allow developers to simply use the programming language itself (e.g., Java, C#, or VB.NET) to access the database and thus benefiting from compile-time type checking, the full expressive power of OO-languages, and the great convenience of advanced development environments.

For example, compare this Native Query in C# for .NET 3.5:

IList<Student> students =
  from Student student in container
  where student.Age < 20 && student.Grade == gradeA
  select student;

... or in Java:

List<Student> students = database.query<Student>(new Predicate<Student>() {
  public boolean match(Student student) {
    return student.getAge() < 20 && student.getGrade().equals(gradeA);
  }
});

As you can see, Native Queries eliminate all strings from queries – they are 100% type-safe, 100% refactorable, and 100% object-oriented.

The same concept applies to our LINQ provider which allows you to smoothly move between Relational db and db4o, for a truly complimentary combination. db4o allows using all the constructs of Microsoft’s Language Integrated Queries (LINQ). db4o LINQ syntax is provided for .NET developers and aimed to make writing db4o code even more native and effortless.

Queries like this:

IEnumerable<Pilot> result =
  from Pilot p in container
  where p.Name.StartsWith("Michael") && p.Points > 2
  select p;

…are perfectly valid within db4o.

Another way to load objects from the database is to use the lazy transparent activation pattern. Suppose you already have the object 'c' of type Car; then you can get the pilote like this:

Pilot p = c.getPilot();

…all Pilote attribute are by db4o as you need them.

Resources:

380 questions
2
votes
1 answer

Db4o - how to rename a field in one step?

As I've read in db4o documentation (.net version), I supposed that to rename a field in a class I would have to add the following to my code (and renaming the actual field in the class, of course): IEmbeddedConfiguration configuration =…
Leandro Gomide
  • 998
  • 1
  • 10
  • 31
2
votes
1 answer

Lazy-loading with db4o

I was wondering if there is any way to lazy-load objects with db4o? I read all the tutorial, and it seems that this functionality doesn't exist. Let's clear my point. For example, let's say I have a House object with 50 complex fields. House 1)…
ouba64
  • 156
  • 4
2
votes
1 answer

Opening objects with a renamed namespace/assembly in db4o

I have a set of objects in db4o format in a .dat file. The objects in that file are OldNamespace.MyObject, OldAssemblyName. The problem is I've since renamed the namespace and assembly to something more permanent. Short of renaming the assembly and…
Chris S
  • 64,770
  • 52
  • 221
  • 239
2
votes
1 answer

DB4o database DatabaseFileLockedException

I would like to access the same db file from different programs in parallel. All programs are running on the same VM. Here is the code I use: private ObjectContainer db; public DatabaseManager(String dbName) { ObjectServer server =…
ilija
  • 543
  • 1
  • 11
  • 19
1
vote
0 answers

Shutdown callback from Jetty to Restlet?

I have been developing a Restlet Application where the db4o database gets opened and closed in the ServerResource or classes below. I started to run into concurrency issues so changed the db4o to the embedded client server mode and had to open the…
Surf's Up
  • 23
  • 2
1
vote
2 answers

I want to know the correct way to use db4o and ask whether it is good choice for my case

I am trying to build a database for a trading system. The data is Forex Tick data and the structure is extremely simple below is the class I use to create object of data. As you noticed, the class has four properties only. Really simple class,…
Wenhao.SHE
  • 1,903
  • 3
  • 17
  • 19
1
vote
1 answer

Db4oTool -Excluding Class From Enhacement

First of all this issue only happens when I run the db4oTool against an assembly taregeting the Mono For Android profile, targeting a normal .Net class library works fine. The issue: I am running the following command as a post build…
Travis
  • 241
  • 1
  • 10
1
vote
1 answer

db4o and alternatives

I've got a Java application that needs to deal with 10s to 100s of gigabytes of data. Any DBMS needs to be embedded. We currently have a db4o solution that is slow, brittle and complicated. I will allow that many of our wounds have been…
user888379
  • 1,343
  • 12
  • 30
1
vote
2 answers

db4o class model transient field

I am using db4o as DBMS and I have a question: Is there any way to specify that I do not want to store a field from the model class in the database? Something similar to @Transient annotation when working with relational databases?
Alina Danila
  • 1,683
  • 1
  • 24
  • 60
1
vote
1 answer

With Db4o How to update an already existing object on which we defined a unique constraint

I create an object on wich the server has a unique constraint defined on one field. But when I want to update the object previously fetched, I get a "UniqueFieldValueConstraintViolationException" without the possibility to commit the object. What is…
taharqa
  • 1,112
  • 1
  • 13
  • 19
1
vote
1 answer

What are the main issues with a db4o server without the persistent classes available?

I was told in a previous question that there can be issues when using db4o server without persistent classes. On the Versant web site, they just say that native queries won't be available. So what are the issues possible in this particular…
taharqa
  • 1,112
  • 1
  • 13
  • 19
1
vote
2 answers

DB4O database size growing on updating objects

I've a java web server application which updates objects to the database every 10 seconds or so. I've noticed that when updating, even if no changes are applied,almost every time the size of the database grows a few KB's. I've used their example…
Kapé
  • 4,411
  • 3
  • 37
  • 54
1
vote
1 answer

db4o - thread safety, embedded server, transactions...general questions

Im working on integrating db4o into my project and I have some questions. I did read the manual and I tried out a few examples, but Im still not sure if I understood everything correctly. Please answer with yes/no (or other answers if there a…
nano7
  • 2,455
  • 7
  • 35
  • 52
1
vote
1 answer

db4o : ActivationDepth seems to have no effect (?)

Can someone please explain to me why setting the Activation Depth seems to have no effect in the code-sample below ? This sample creates 'Block'-objects which all have a number and a child-block. Since the ActivationDepth is set to '2', I would…
Tim
  • 183
  • 1
  • 1
  • 4
1
vote
1 answer

Db4o and object identity

I'm learning db4o data base, I'm planing to use it 3-tier project. I don't fully understand the concept of object identity in db4o. Suppose we have a class like this: public class User { public Guid Id; public String SomeString; public…
Alex Burtsev
  • 12,418
  • 8
  • 60
  • 87