a 3d database ORM experiment. (used in two commercial projects)

Overview

Android-TriOrm

a 3d database ORM experiment for Android. (used in two commercial projects). based around small tables concept and JVM Serialization.

Android Arsenal

How to use

simply fork or download the project, you can also download and create .aar file yourself.

Explanation

TriOrm is a very light, simple and efficient ORM with partial SQL wrapping, with the following theme:

  • every Object (TriData extension) is serialized and saved in the database.
  • you can only query by three fields: id, time_created and type.
  • familiar no fuss Builder pattern to construct database.
  • easy API to query, save and load typed objects.
  • a very small usage of annotation(Optional).
  • no learning curve whatsoever, no Boiler-plate code.
  • Database is ready to use in less than couple of minutes.
  • everything is typed.
  • most of the presistent is carried by JVM Serialization and minimal small SQL table.

construct your Model/Tables

Simply extend TriData with the following annotations(Optional).

@TriTable(dbName = "myDataBase", tableName = "user")
public class User extends TriData {
    public String firstName = "John";
    public String lastName  = "Dow";

    public User() {
    }

    public User(String id) {
        super(id);
    }
}

@TriTable(dbName = "myDataBase", tableName = "location")
public class Location extends TriData {
    public String city    = "city";
    public String state   = "state";

    public Location() {
    }

 }

every TriData has the following indexed/query-able properties with getters/setters:

  • setId(..) - you can set the id or it will be set automatically for you.
  • setType(..) - some auxiliary field.
  • setTimeCreated(..) - also set-up for you by default.

construct your Database

constructing a database takes one line of code

new TriDatabase.Builder(this).addTable(User.class).addTable(Location.class).build();

and without annotations:

new TriDatabase.Builder(this).name("myDataBase").addTable("user", User.class).addTable("location", Location.class).build();

Saving into your Database

Simply invoke the save() method on your extended TriData object.

User user       = new User();

user.setId("theDude");
user.setType("Java programmer");

user.firstName  = "Jimi";
user.lastName   = "Hendrix";

user.save();

loading a single object from your Database

Simply use the TriOrm.load(..) Singleton and use your typed object.

User user = TriOrm.load(User.class, "theDude");

querying from your Database

Simply use the TriOrm.query(..) builder Singleton and use your typed object.

ArrayList<User> list_users = TriOrm.query(User.class).timeCreatedFrom(0).timeCreatedTo(100).type("Java programmer").build().query();

you can query anything from the three properties: id, timeCreated and type.

getting an instance of a table

Simply use the TriOrm.table(..) Singleton and use your typed object. With table you can have more options and some sandbox methods.

TriTable<User> table = TriOrm.table(User.class);

Important Notes

The presistent layer is built around JVM Serialization, therefore there are important considerations for when evolving your model/tables like any other database solution, beware of the folowing:

  • TriData is based on JVM Serialization, therefore:
    • adding new fields is compatible.
    • deleting/renaming exiting fields is not compatible, Therefore you will have to implement your writeObject/readObject and be smart about it.
    • adding new methods, altering previous methods is incompatible.
  • look here for more info Durable Java: Serialization
  • I recommend using primitive types as much as possible when designing the model/table.
  • for best performence and compatibility control, you can experiment with Externalizable interface for reflection free.
  • contributions are most welcome with regards to compatiblity/performence.

Dependencies

  • AOSP

Terms

Contact Author

You might also like...
Performance comparison of Android ORM Frameworks
Performance comparison of Android ORM Frameworks

Performance comparison of Android ORM Frameworks At the moment there are a lot of ORM-libraries for the Android OS. We reviewed the most popular ones

JAKO: Just Another Kotlin Orm (PostgreSQL)
JAKO: Just Another Kotlin Orm (PostgreSQL)

JAKO: Just Another Kotlin Orm (PostgreSQL) JAKO is a simple, minimal, no-dependency library to build and execute postgresql statements using a fluent

Insanely easy way to work with Android Database.

Sugar ORM Insanely easy way to work with Android databases. Official documentation can be found here - Check some examples below. The example applicat

Realm is a mobile database: a replacement for SQLite & ORMs

Realm is a mobile database that runs directly inside phones, tablets or wearables. This repository holds the source code for the Java version of Realm

An Android library that makes developers use SQLite database extremely easy.

LitePal for Android 中文文档 LitePal is an open source Android library that allows developers to use SQLite database extremely easy. You can finish most o

Insanely easy way to work with Android Database.

Sugar ORM Insanely easy way to work with Android databases. Official documentation can be found here - Check some examples below. The example applicat

An Android helper class to manage database creation and version management using an application's raw asset files

THIS PROJECT IS NO LONGER MAINTAINED Android SQLiteAssetHelper An Android helper class to manage database creation and version management using an app

SquiDB is a SQLite database library for Android and iOS

Most ongoing development is currently taking place on the dev_4.0 branch. Click here to see the latest changes and try out the 4.0 beta. Introducing S

Compile time processed, annotation driven, no reflection SQLite database layer for Android

SqliteMagic Simple yet powerful SQLite database layer for Android that makes database handling feel like magic. Overview: Simple, intuitive & typesafe

Comments
  • Which is a license of TriOrm, GPL or Apache License 2.0?

    Which is a license of TriOrm, GPL or Apache License 2.0?

    see: https://github.com/HendrixString/Android-TriOrm/blob/master/LICENSE and https://github.com/HendrixString/Android-TriOrm/blob/master/README.md#terms

    Conflicting license LICENSE file and README.md. Which is correct?

    opened by keima 2
Releases(v1.0.0)
Owner
Tomer Shalev
@Shutterfly
Tomer Shalev
A blazing fast, powerful, and very simple ORM android database library that writes database code for you.

README DBFlow is fast, efficient, and feature-rich Kotlin database library built on SQLite for Android. DBFlow utilizes annotation processing to gener

Andrew Grosner 4.9k Dec 30, 2022
LiteOrm is a fast, small, powerful ORM framework for Android. LiteOrm makes you do CRUD operarions on SQLite database with a sigle line of code efficiently.

#LiteOrm:Android高性能数据库框架 A fast, small, powerful ORM framework for Android. LiteOrm makes you do CRUD operarions on SQLite database with a sigle line

马天宇 1.5k Nov 19, 2022
greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases.

Check out ObjectBox Check out our new mobile database ObjectBox (GitHub repo). ObjectBox is a superfast object-oriented database with strong relation

Markus Junginger 12.6k Jan 3, 2023
Android ORM

Shillelagh Shillelagh is an sqlite library. It was built to make life easier. The entire library was built around simplicity when using sqlite in Andr

Andrew Reitz 49 Sep 11, 2020
Compile-time active record ORM for Android

Ollie Compile-time active record ORM for Android. Multiple mapping methods. SQLiteDatabase-like interface (QueryUtils.java). Lightweight query builder

Michael Pardo 423 Dec 30, 2022
lightweight and minimalist ORM for Java/Android. works with SQLite & MySQL. (not actively maintained)

Description ORMAN is an minimalistic and lightweight ORM framework for Java which can handle your common database usage without writing SQL and strugg

Ahmet Alp Balkan 246 Nov 20, 2022
ORMDroid is a simple ORM persistence framework for your Android applications.

ORMDroid is a simple ORM persistence framework for your Android applications, providing an easy to use, almost-zero-config way to handle model persist

Ross Bamford 87 Nov 10, 2022
AndroidQuery is an Android ORM for SQLite and ContentProvider which focuses on easy of use and performances thanks to annotation processing and code generation

WARNING: now that Room is out, I no longer maintain that library. If you need a library to easy access to default android ContentProvider, I would may

Frédéric Julian 19 Dec 11, 2021
lightweight and minimalist ORM for Java/Android. works with SQLite & MySQL. (not actively maintained)

Description ORMAN is an minimalistic and lightweight ORM framework for Java which can handle your common database usage without writing SQL and strugg

Ahmet Alp Balkan 246 Nov 20, 2022
An ORM for Android with type-safety and painless smart migrations

Android Orma Orma is a ORM (Object-Relation Mapper) for Android SQLiteDatabase. Because it generates helper classes at compile time with annotation pr

The Maskarade project 440 Nov 25, 2022