GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - HendrixString/Android-TriOrm: A 3d database ORM experiment. (used in two commercial projects)

BranchesTags
Open more actions menu

Latest commit

 

History

30 Commits
30 Commits

Folders and files

NameName
Last commit message
Last commit date
src/main
src/main
 
 
.gitignore
.gitignore
 
 
Android-TriOrm.iml
Android-TriOrm.iml
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
proguard-rules.pro
proguard-rules.pro
 
 
triorm.iml
triorm.iml
 
 

Repository files navigation

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

  • completely free source code. Apache License, Version 2.0.
  • if you like it -> star or share it with others

Contact Author

  • [email protected]
  • Google+ TomershalevMan
  • Facebook - HendrixString

About

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

Topics

androidandroid-triormormsqlite

Resources

Readme
Activity

Stars

19 stars

Watchers

3 watching

Forks

3 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.