DB4O Community Edition 8.1.9 release, Java Lambda query the database

Db4o is an object-oriented database, persistence can be complex object structure, support the single-user mode, multi-user mode.

This new version put some useful command Java7-Java11 of make up, mainly to compile Java11 of Lambda statement,
Lambda at the bottom using a new directive, this version of Db4o is based Java7, to patch compiled Lambda. On OpenJDK11 test.

Java Lambda many years, to support Lambda query the database library, little,
here directly into the Lambda Db4o, a simple query directly compiled into a database query.

Examples of use

initialization

public static class Detail {
    @Indexed
    public long type;
    public String memo;
    public Record record;
}

public static class Record {
    @Indexed
    public String name;
    public String noName;
    @Indexed
    public double indexField;
    public double noIndexField;
    public Detail detail;
}


String dbname = "index.j.db";
var ecfg = Db4oEmbedded.newConfiguration();
var memory = new MemoryStorage();
ecfg.file().storage(memory);
ecfg.common().add(new TransparentActivationSupport());
ecfg.common().add(new TransparentPersistenceSupport());
ecfg.file().generateUUIDs(ConfigScope.GLOBALLY);

try (var oc = Db4oEmbedded.openFile(ecfg, dbname)) {
}

 

Insert Object

try (var see = oc.ext().openSession()) {
    for (int i = 0; i < 1000; i++) {
        for (int j = 0; j < 50; j++) {
            var r = new Record();
            r.name = "Name-" + i;
            r.noName = r.name;
            r.indexField = (double) i;
            r.noIndexField = i;
            r.detail = new Detail();
            r.detail.record = r;
            r.detail.type = j;
            r.detail.memo = r.name + " on meno";
            see.store(r);
        }
    }
    see.commit();
}

 

Java Lambda query data, a realization of all expression, is to upgrade the code to run on the database phrase

var rs = see.query((Record r) -> r.indexField == value);

If you want to run the same as ordinary Lambda, the field name on the right side

Db4o Community Edition download

Product Comparison
Db4o shining object-oriented technology.
iBoxDB performance and security for data isolation.

Guess you like

Origin www.oschina.net/news/110252/db4o-8-1-9-released