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
3
votes
1 answer

db4o openfile file format incompatible

I'm trying to create a generic helper class for db4o. I created a static class which should work as helper in each applications pages. Here is my code: public final class DatabaseHelper implements IDatabaseHelper{ private static ObjectContainer…
Pier Giorgio Misley
  • 5,305
  • 4
  • 27
  • 66
3
votes
2 answers

Working with large collections in db40 (.net)

I would like to use db4o as the backend of a custom cache implementation. Normally my program involves loading into memory some 40,000,000 objects and working on them simultaneously. Obviously this requires a lot of memory and I thought of perhaps…
Jeffrey Cameron
  • 9,975
  • 10
  • 45
  • 77
3
votes
1 answer

DB4o Linq query - How to check for null strings

Hey there - simple query: var q = (from SomeObject o in container where o.SomeInt > 8 && o.SomeString != null //Null Ref here select o; I always get a null reference exception. If I use String.IsNullOrEmpty(o.SomeString) the query takes…
Dave Bish
  • 19,263
  • 7
  • 46
  • 63
3
votes
1 answer

Is there a tool that will create Java or .NET classes from a db4o database file?

I have a db4o database file. Is there a tool that will generate Java or .NET classes (source) from this database?
dommer
  • 19,610
  • 14
  • 75
  • 137
3
votes
2 answers

Moving webshop storage to NoSQL solution

If you had a webshop solution based on SQL Server relational DB what would be the reasons, if any, to move to NoSQL storage ? Does it even make sense to migrate datastores that rely on relations heavily to NoSQL? If starting from scratch, would you…
mare
  • 13,033
  • 24
  • 102
  • 191
3
votes
3 answers

How to use an OSGi service from a web application?

I'm trying to develop a web application that is going to be launched from a HTTP OSGi service, this application needs to use other OSGi service (db4o OSGi), for what I need a reference to a BundleContext. I have tried two different approaches to get…
Jaime Soriano
  • 7,309
  • 2
  • 33
  • 45
3
votes
1 answer

UniqueConstraint in EmbeddedConfiguration

I just started using db4o on C#, and I'm having trouble setting the UniqueConstraint on the DB.. here's the db4o configuration static IObjectContainer db = Db4oEmbedded.OpenFile(dbase.Configuration(), "data.db4o"); static IEmbeddedConfiguration…
GaiusSensei
  • 1,860
  • 4
  • 25
  • 44
3
votes
0 answers

Using db4o with multiple application instances under medium trust

I recently stumbled over the object database engine db4o which I think looks really interesting. I would like to use it in an ASP.NET MVC application that will be deployed to a shared hosting environment under medium trust. Because of the trust…
Anders Fjeldstad
  • 10,724
  • 2
  • 33
  • 50
3
votes
1 answer

Object DB vs Classic MySQL

We're in the process of choosing a new design for our application (DB change included) and we were considering object databases (specifically db4o). We've built a benchmark test and surprisingly, so far, all tests point that a Hibernate + MySQL…
Eugen
  • 1,537
  • 7
  • 29
  • 57
3
votes
1 answer

Sorting on number field db4o Android

I am using db4o database for storing data in my Android application. I want to sort objects on Number field. But, when I use query.descend("number").orderDescending();, I am getting NullPointerException. Why?
Unnati
  • 2,441
  • 17
  • 37
3
votes
1 answer

Maintaining backwards compatibility with my object database?

I am writing an application using an object database (db4o) and in agile fashion will be starting from a small, minimal implementation and iteratively adding features from there, while releasing new versions of the software as I go. The main…
Alex Baranosky
  • 48,865
  • 44
  • 102
  • 150
3
votes
1 answer

Lambda syntax in linq to db4o?

I know the following is possible with linq2db4o from Apple a in db where a.Color.Equals(Colors.Green) select a What I need however is something that allows me to build my query conditionally (like I can in other linq variants) public…
Boris Callens
  • 90,659
  • 85
  • 207
  • 305
3
votes
4 answers

Db4o query: find all objects with ID = {anything in array}

I've stored 30,000 SimpleObjects in my database: class SimpleObject { public int Id { get; set; } } I want to run a query on DB4O that finds all SimpleObjects with any of the specified IDs: public IEnumerable GetMatches(int[]…
Judah Gabriel Himango
  • 58,906
  • 38
  • 158
  • 212
3
votes
2 answers

Is Using Db4o For Web Sites a judicious choice?

Is using Db4o as a backend datastore for a Web site (ASP.NET MVC) a judicious choice as an alternative to MS SQL Server ?
Yoann. B
  • 11,075
  • 19
  • 69
  • 111
3
votes
3 answers

db4o Defragment deletes all objects in the database

I am using db4o 8.0. The db4odatabase file size is 21MB. The database has following Objects in it. User : There is 1 user in db. PostedMessage : There are 10000 postedMessages in db. I delete all 10000 PostedMessages. Then I try to defragment the…