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
1
vote
1 answer

WPF DataGrid issue with db40

I am using the following code to populate a wpf datagrid with items in my db4o OODB: IObjectContainer db = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(), "C:\Dev\ContractKeeper\Database\ContractKeeper.yap"); var contractTypes =…
Rich Blumer
  • 960
  • 1
  • 15
  • 26
1
vote
1 answer

DB4O Insert winery that does not exist

I'm doing a test with DB4O. I am trying to insert data. The problem I have is: When I insert the name of winery and D.O. I have to insert only if not exist in the database. How could i do it? This is my insert code: Scanner teclado=new…
Funereal
  • 653
  • 2
  • 11
  • 32
1
vote
1 answer

DB4O persistence and non-close commit

I'm using DB4O with transparent persistence/activation using msbuild enhancement as my preferred database for an ASP.NET MVC Intranet collaborative editing application. I have a few simple questions: If I call commit() after every set of change,…
Bill
  • 1,271
  • 1
  • 10
  • 13
1
vote
2 answers

Exception in thread "main" java.lang.UnsupportedOperationException

I am trying to get an ordered list of vehicles using Native Query in Java. I am using two methods, the first to get the vehicles, and the second method to order the list. I get this error: Exception in thread "main"…
user3325719
  • 75
  • 4
  • 14
1
vote
1 answer

Stored IEnumerable dissapears on restart debug, but recreating IObjectServer and IObjectClient in one unit test is ok

I'm storing an IUser object in a Db4o database as follows (client is an IObjectClient): public Guid AddUser(IUser user) { lock (userLock) { user.Id = Guid.NewGuid(); client.Store(user); client.Commit(); } …
Boris Callens
  • 90,659
  • 85
  • 207
  • 305
1
vote
1 answer

checking if DB4o ObjectContainer is closed

DB4O doesn't seem to provide a method to check if the database (ObjectContainer) is closed. So right now, this is the code I use to see if it's closed. I get the feeling there is a better way to do this. public ObjectContainer getDb() { if…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
1
vote
1 answer

DB4o update vs insert

Assuming you are using DB4O with the standard configuration and out-of-the-box - meaning, you are using DB4O's standard internal id scheme, as per below**. First, as an assumption, when updating or inserting an object into the database, the…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
1
vote
1 answer

db4o - how do I get a distinct list of classes contained in a .db4o DB file?

Say I open a .db4o file. What would be the Java code (psuedo) that would generate a list of unique Java CLASSES/TYPES contained in the database? I am sure I could write the code to do it, but I am afraid it could be quite slow. Is there a good way…
user1604294
1
vote
1 answer

Non-GPL alternative to db4o

I'm developing a closed source Android application. I was using db4o to persist data on the device and I found it very easy and straightforward to use. Unfortunately I didn't get informed about it's license which is GPL until now. As far as I…
fweigl
  • 21,278
  • 20
  • 114
  • 205
1
vote
1 answer

How to circumvent huge files for large embedded db4o databases

I'm thinking about using an embedded db4o database for storing calculation results of a simulation tool. The simulation results can be quite large (up to some GBs for a single run, so the practical size of the database might probably be in the range…
bigge
  • 1,488
  • 15
  • 27
1
vote
1 answer

db4o Transparent Activation - Null Exception on retrieving children values of a node

I create a tree of nodes, and I store it in Database for Object Oriented (db4o). Because I want an efficient loading of the nodes from the database, I use Transparent Activation, and I implement the Activatable interface. My Node class is the…
Traveling Salesman
  • 2,209
  • 11
  • 46
  • 83
1
vote
1 answer

Db4O - Can I save a String?

I have the following code: Assert.IsTrue(Repository.FindAll().Count() == 0); string newString = "New String"; Repository.Save(newString); Assert.IsTrue(Repository.FindAll().Count() == 1); But it is failing. I suppose it has…
Miguel Ping
  • 18,082
  • 23
  • 88
  • 136
1
vote
1 answer

Storing a tree in db4o by just storing the root object

In my java code, I created a tree, where a node in the tree is of type Node. The node has a name, attribute and children of type Node. I am using db4o in order to store the tree. I am doing that by simply storing the root node of the tree. However,…
Traveling Salesman
  • 2,209
  • 11
  • 46
  • 83
1
vote
1 answer

is there any way to implement TransparentActivation without referencing db4o libs into model?

to get directly to my point: I want to have independent object model where I won't reference any libraries of database engine so that I will be able to use that model in multiple object or document databases (such as RavenDB, db4o, eloquera etc.) on…
Tomas Panik
  • 4,337
  • 2
  • 22
  • 31
1
vote
1 answer

Loading data from db4o under .net 4.0 in 3.5

I have a server running .net 4.0 which is creating a db4o database and sending it to a client. The client is running .net 3.5, and cannot open the database (This used to work when the server was also 3.5). The client throws a Db4oIOException with a…
andypaxo
  • 6,171
  • 3
  • 38
  • 53