Android ORM

Overview

Shillelagh

Library Icon

Build Status Android Arsenal

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

Quick and dirty.

  • Create your model objects, the ones you want to persist
  • Add the @Table annotation to the model class, and make sure you have a field @Id long id
  • Create your SQLiteOpenHelper and use Shillelagh.createTable to make your tables
  • Create an instance of Shillelagh
  • Create and save your objects!

For how to use see the example or the JavaDocs.

Supported Types

Supported Types (and corresponding primitives)

  • Integer
  • Double
  • Float
  • Long
  • Short
  • String
  • Date
  • Boolean

One to Many and One to One

One to one and one to many relationships are supported. You will need to make sure that the child objects are annotated like any other tables. For one to many, make sure you use a list, arrays are currently not supported.

Blobs

Byte arrays are supported with nothing out of the ordinary needing to be done. If you would like to save another object type as a blob, you will need to tell Shillelagh that it should be serialized by adding @Column(isBlob = true) to the annotation. These objects MUST also implement the Serializable interface.

Other Notes

  • Constructors must be provided at package protected level or higher (Put in a ticket if there is a legitimate use case for private).
  • Inner classes MUST be marked static.
  • Don't forget to update your database version if you change your models (Also create migration scripts).
  • For proguard just add -keep class **$$Shillelagh { *; } to your rules.
  • If you do not provide a defualt constructor, Shillelagh will attempt to use the constructor you provided and pass in null.

Download

dependencies {
  ...
  implementation 'com.andrewreitz:shillelagh:0.5.0'
  provided 'com.andrewreitz:shillelagh-processor:0.5.0'
  ...
}

License

Copyright 2015 Andrew Reitz

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
under the License is distributed on an "AS IS" BASIS,
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
the License for the specific language governing permissions and
under the License.
Comments
  • Lower minimum dependency

    Lower minimum dependency

    Right now you are manually including API Level 15, but most of the functionality you're relying on has been present in Android since before that (at least up until API Level 10, where RXJava is supported). Previously, you would receive an error message like this if attempting to use this library on an earlier version;

    ERROR: Debug has an indirect dependency on Android API level 15, but minSdkVersion for variant 'Debug' is API level 10
    

    After this change, I was able to build a project and run it on an Android 2.3.7 device properly.

    Keep up the great work! This library shows a ton of promise.

    opened by iainconnor 11
  • Null Pointer from build

    Null Pointer from build

    at shillelagh.internal.TableObject.getSchema(TableObject.java:141)
    at shillelagh.internal.TableObject.toString(TableObject.java:455)   at shillelagh.internal.ShillelaghProcessor.process(ShillelaghProcessor.java:120)
    

    Any idea what could cause this issue?

    opened by hongzhou85 10
  • Unable to create table for class, Are you missing @Table annotation?

    Unable to create table for class, Are you missing @Table annotation?

    Weirdly enough, the model does have the Table annotation...

    @Table
    public class TestModel {
        @Id(name = Constants.COLUMN_ID)
        public long _id;
    
        @Column(name = Constants.COLUMN_TEST)
        public String testColumn;
    
        public TestModel (String testColumn) {
            this.testColumn = testColumn;
        }
    }
    

    The above error is followed by this one on the Logcat trace: Caused by: java.lang.ClassNotFoundException: com.tests.shillelagh.models.TestModel$$Shillelagh

    Looks to me the annotation processor is having some issues...

    opened by mradzinski 5
  • Allow Named Tables and Columns

    Allow Named Tables and Columns

    Right now shillelagh uses the name of the field on the object. This is okay, but for more flexibility and consisness users should be able to name their tables and colmns.

    opened by AndrewReitz 5
  • Better Collection Support

    Better Collection Support

    The only real way to do collections of primitives is to mark them as a blob. The problem then becomes that Lists and Maps are not serializable by default. Update the project to try to cast any of these types to serializable.

    opened by AndrewReitz 1
  • Better constructor support

    Better constructor support

    Currently shillelagh will pass in null for each parameter of the constructor. This is works great if there are no constraint checks, but if there are you will need to either provide an empty constructor or remove the constraints.

    There is probably a better way of doing this, like how gson or objenesis does it.

    opened by AndrewReitz 1
  • Updated How Selects Are Done

    Updated How Selects Are Done

    Using Observables for Selects is fine until the select size gets very large.

    There should be better ways of limiting this to keep the time it takes down. Raw queries can be used but are really sloppy. There should be something better but is still relatively type safe and fast.

    enhancement 
    opened by AndrewReitz 1
  • Add ability to choose if a parent should drop all childern

    Add ability to choose if a parent should drop all childern

    If you many a one to many or one to one relationship when you drop the parent it leaves the childeren. Add the ability to pass a flag to the drop function to drop the parent and all children.

    opened by AndrewReitz 0
Releases(v0.5.0)
  • v0.5.0(Nov 30, 2014)

    • Added ability to define column, id, and table names.
    • Renamed @Field annotation to @Column.
    • Removed @OrmOnly annotation and need for empty no arg constructors.
    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Nov 16, 2014)

Owner
Andrew Reitz
Android / Kotlin
Andrew Reitz
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
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
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
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
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
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

Alexey Zatsepin 328 Dec 21, 2022
a 3d database ORM experiment. (used in two commercial projects)

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

Tomer Shalev 19 Nov 24, 2021
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

Alessio 6 May 27, 2022
Active record style SQLite persistence for Android

ActiveAndroid ActiveAndroid is an active record style ORM (object relational mapper). What does that mean exactly? Well, ActiveAndroid allows you to s

Michael Pardo 4.7k Dec 29, 2022
Object-relational mapping for Android

RushOrm Object-relational mapping for Android RushOrm replaces the need for SQL by mapping java classes to SQL tables. What is the aim? The aim is to

Stuart Campbell 172 Nov 11, 2022
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

null 2.6k Dec 16, 2022
requery - modern SQL based query & persistence for Java / Kotlin / Android

A light but powerful object mapping and SQL generator for Java/Kotlin/Android with RxJava and Java 8 support. Easily map to or create databases, perfo

requery 3.1k Dec 29, 2022
Core Data for Android

NexusData Core Data for Android NexusData is an object graph and persistence framework for Android. It allows for organizing and managing relational d

Dia Kharrat 71 Nov 11, 2022
A simple NoSQL client for Android. Meant as a document store using key/value pairs and some rudimentary querying. Useful for avoiding the hassle of SQL code.

SimpleNoSQL A simple NoSQL client for Android. If you ever wanted to just save some data but didn't really want to worry about where it was going to b

Colin Miller 389 Sep 25, 2022
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

Lin Guo 7.9k Dec 31, 2022