Add it to your project as Maven dependency:
<dependency>
<groupId>com.ohmdb</groupId>
<artifactId>ohmdb-all</artifactId>
<version>1.0.0</version>
</dependency>
Add this code to your project and run it:
import com.ohmdb.api.*;
class Person { public String name; public int age; }
public class Main {
public static void main(String[] args) {
Db db = Ohm.db("ohm.db");
Table<Person> persons = db.table(Person.class);
Person $p = persons.queryHelper();
Person p1 = new Person();
p1.name = "Niko";
p1.age = 30;
long id = persons.insert(p1);
Person p2 = persons.get(id);
persons.createIndexOn($p.age);
Person[] adults = persons.where($p.age).gte(18).get();
db.shutdown();
}
}
OhmDB vs RDBMS vs NoSQL - No Silver Bullet!
| OhmDB | RDBMS | NoSQL | |
|---|---|---|---|
| Data complexity | Unlimited | Unlimited | Limited |
| Relations | Graph-based | Yes | Graph-based or none |
| JOINS | Fast | Slow | Fast or none |
| Transactions | ACID | ACID | Limited |
| Schema | Strict | Strict | Flexible |
| Schema migration | Automatic | Manual | Automatic |
| Agile-friendly | Yes | No | Yes |
| Data capacity | Limited to RAM | Unlimited | Unlimited |
| Scale Up | Yes | Yes | Yes |
| Replication | Not yet | Yes | Yes |
| Partitioning | Not yet | Yes | Yes |
Let's learn Java 8 at java8.org!