lightweight and minimalist ORM for Java/Android. works with SQLite & MySQL. (not actively maintained)

Related tags

O/R Mapping orman
Overview

Description

ORMAN is an minimalistic and lightweight ORM framework for Java which can handle your common database usage without writing SQL and struggling with lots of jar dependencies.

It is written in pure java so that you can use ORMAN in your small database-consuming Java projects or Android apps very easily!

Documentation

Want to learn how to use ORMAN framework in a few minutes? Please read our Wiki.

Pros & Cons

ORMAN can...

  • Create tables from your Java classes (POJOs).
  • Create columns from fields of your Java classes.
  • Work with MySQL, SQLite, and even on Android with SQLite (cool!)
  • Allows you to create safe and easy SQL queries.
  • Manage OneToOne, OneToMany, ManyToMany etc. relationships between entities easily.
  • Let you code your database consumer program very quickly.

ORMAN is...

  • Open source (licensed under Apache License 2.0)
  • Lightweight and small (~170 kb) (alternatives like Hibernate are ~4 mb)
  • Easy to install
  • Easy to configure with annotations, no XML config files etc. needed
  • Easy to learn
  • SQL:1999 standards compliant.
  • Looking for contributors
    • a developing project and needs contribution in many levels such as documentation, testing, demo app development, feature development, architecture consultancy etc.

ORMAN ...

  • is NOT a solution that covers detailed database usage.
  • is NOT an enterprise or bug-free solution.
  • does NOT support changes in database schema. (create once, use always)
  • does NOT have a transaction manager.
  • may NOT have backwards compatibility with previous versions.

Dev Community

Feel free to write wikis (if you understand how framework works) or follow commit logs by subscribing to our commit-logs list at groups.google/orman-commits.

You can reach some framework statistics about framework here and our master branch nightly builds are here

Contributors

Bitdeli Badge

Comments
  • Problem with cursor finalizing

    Problem with cursor finalizing

    Every request to db gives me following errors:

    • 09-15 12:07:14.417: ERROR/Cursor(16962): Finalizing a Cursor that has not been deactivated or closed. database = /data/data/com.sample.project/databases/app.db, table = null, query = SELECT * FROM stream WHERE stream.id LIKE '734';
    • 09-15 12:07:14.417: ERROR/Cursor(16962): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here

    Am I doing something wrong or something wrong with framework? Must admit, that transactions work anyway, but I get all this errors and app crashes.

    Bug Critical 
    opened by almozavr 14
  • Android - MappingSessionAlreadyStartedException

    Android - MappingSessionAlreadyStartedException

    I start the Mapping Session in my Activity's onCreate method. Once I back out of the application and restart it once again I get the following exception:

    11-27 17:55:53.448: E/AndroidRuntime(754): Caused by: org.orman.mapper.exception.MappingSessionAlreadyStartedException: Mapping session has already been started. Do not use start method more than once.
    

    The app then crashes, but the next time I open the app, it works fine.

    public static void initOrmanMappingSession(Class<?>[] entityClasses,  Database database) {
            System.gc();
    
            MappingSession.getConfiguration().setCreationPolicy(SchemaCreationPolicy.CREATE_IF_NOT_EXISTS);
            MappingSession.registerDatabase(database);
            for(Class<?> clazz : entityClasses) {
                MappingSession.registerEntity(clazz);
            }
    
            MappingSession.startSafe();
    }
    
    opened by ragunathjawahar 12
  • Error query Inserting  % '

    Error query Inserting % '

    I need to store a string like this :

    <![CDATA[<div id='new'><div class="chapeaux"><ul>
    

    And it's giving me Bad format exception in the insert query because of the ' and the %

    How can I avoid this?

    opened by Antpachon 9
  • Index problem when using Object.object entity

    Index problem when using Object.object entity

    When there is:

    @entity
    public class Message extends Model{
    
        @PrimaryKey(autoIncrement = true)
        public int rowId;
        @Index
        public int id;
        public int title;
        public int text;
        @OneToOne
        public Message parentMessage;
    }
    

    error occurs saying column parent_message is not unique

    It's a some kind of restriction, but! One should feel free to use unique indexes even in this situation. P.S. everything works if I use set @Index as not unique.

    opened by almozavr 9
  • android.database.sqlite.SQLiteException: Can't downgrade database from version 35 to 33

    android.database.sqlite.SQLiteException: Can't downgrade database from version 35 to 33

    In order to upgrade my schema I've created my own SQLiteOpenHelper which does the upgrades at startup. In my last update, something bad happened: Users are reporting this error...

    Caused by: android.database.sqlite.SQLiteException: Can't downgrade database from version 35 to 33 at android.database.sqlite.SQLiteOpenHelper.onDowngrade(SQLiteOpenHelper.java:307) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:168) at org.orman.dbms.sqliteandroid.SQLiteAndroid.(SQLiteAndroid.java:39) [...]

    And indeed, my db version went from 33 to 34. I saw in the orman code the following line:


    public class SQLiteAndroid extends SQLiteOpenHelper implements Database { private static final int SQLITE_VERSION = 33; //TODO read from somewhere else ASAP


    ... and I'm suspecting that this could be causing the problem.

    Right now I'm a bit at a loss here, do you see a possibility for a quick fix?

    opened by hippiefahrzeug 6
  • Model.update() problem

    Model.update() problem

    Hi.

    I'm forcing with strange update() problem. I have a quite complicated entity which has ManyToMany (or OneToMany) and a problem appears when I try to update entity which is already in DB. So even if I fetch entity from DB and then update the orman fails to do it giving following exception:

    09-19 09:26:19.830: ERROR/AndroidRuntime(318): Caused by: org.orman.dbms.exception.QueryExecutionException:
             Query execution error: SQLiteAndroid error:android.database.sqlite.SQLiteException:
             near ".": syntax error: UPDATE stream SET message=1, messages_using_it=(com.sample.project.model.Message@f879683e),
             title='New discussion', users=(com.sample.project.model.User@f6fdfd03)  WHERE row_id = 1;
    09-19 09:26:19.830: ERROR/AndroidRuntime(318):     at org.orman.dbms.sqliteandroid.QueryExecutionContainerImpl.throwError(QueryExecutionContainerImpl.java:30)
    09-19 09:26:19.830: ERROR/AndroidRuntime(318):     at org.orman.dbms.sqliteandroid.QueryExecutionContainerImpl.executeOnly(QueryExecutionContainerImpl.java:41)
    09-19 09:26:19.830: ERROR/AndroidRuntime(318):     at org.orman.mapper.Model.update(Model.java:164)
    
    Bug 
    opened by almozavr 6
  • org.orman.mapper.exception.FieldNotFoundException: Could not find property (field)

    org.orman.mapper.exception.FieldNotFoundException: Could not find property (field)

    Hi. I'm actually using orman on android and I think it's a really convenient orm.

    Actually, I got a serious issue. I found a way to fix it temporary but It's not as clean as I would want. Let me explain:

    I got 1 class named Noeud (node) and 1 classe named Equipement (equipment).

    Noeud has two ManyToOne relationships. One with itself (on field "parent") and one to Equipement (on field "localisation").

    My problem is: when I try to access equipment (by using node.getEquipements()), I got the following error: org.orman.mapper.exception.FieldNotFoundException: Could not find property (field) parent in Equipement.

    I checked, double-checked, triple-checked my ManyToOne declarations (code below) but problem is still here). I have the impression that all ManyToOne associations of one class are sharing their foreign key names.

    I solved the problem by renaming "localisation" field on Equipement to "parent" and it seems to work but it could be a problem if I was right about the cause.

    class Noeud extends Model<Noeud> {
        @OneToMany(onField = Equipement.PROP_LOCALISATION, toType = Equipement.class, load = LoadingPolicy.LAZY)
        private EntityList<Noeud, Equipement> equipements = new EntityList<Noeud, Equipement>(Noeud.class, Equipement.class, this);
    
        @OneToMany(onField = "parent", toType = Noeud.class, load = LoadingPolicy.LAZY)
        private EntityList<Noeud, Noeud> children = new EntityList<Noeud, Noeud>(Noeud.class, Noeud.class, this);
    }
    
    class Equipement extends Model<Equipement> {
        public static final String PROP_LOCALISATION = "localisation"; //actually renamed to "parent"
    
        @ManyToOne(load = LoadingPolicy.LAZY)
        private Noeud localisation; //also renamed to "parent"
    }
    

    Do that sounds familiar to you? Did I miss something in documentation or in my code?

    Best regards.

    opened by fdutey 5
  • License to release build

    License to release build

    Currently we don't have any distributable builds. However when we have, we should distribute code under an appropriate license so that developers can use it even in their commercial applications.

    Any license suggestions for the framework? Examples from other frameworks?

    Idea 
    opened by ahmetb 5
  • Remove mandatory to have a auto-increment @PrimaryKey field on the referenced entity

    Remove mandatory to have a auto-increment @PrimaryKey field on the referenced entity

    I found orman very simple to understand and easy to maintain. It's usage is really awesome. But because of restriction to use auto-increment field I can't use it in my project and that's way:

    1. I have many entities with fields of ref. entities
    2. Many of ref. entities have the "id" field which I get from server (btw it's a client-server app, some kind of advanced messenger)
    3. Mandatory to have auto-increment field disallows creating primary keys for my "id" fields.
    4. So dozens of duplicates :(
    5. As I use it for Android, db size and performance means a lot.

    I appreciate your work (framework is really cool comparing to db4o, ormlite etc.) and hope one day my issue would be accepted. Thanks.

    opened by almozavr 4
  • Cannot set Nullable UNIQUE constraint on a column (SQLite on Android)

    Cannot set Nullable UNIQUE constraint on a column (SQLite on Android)

    I'm trying to create a column which has the following constraints:

    1. The column contains UNIQUE values
    2. The column can have NULL values.
    3. This is not the PRIMARY KEY column.

    Note that SQLite allows NULL values in columns designated as UNIQUE - Reference

    Since Orman uses the @Index annotation do designate UNIQUE-ness, I tried the following:

    @Entity
    public class Node extends Model<Node> {
    
        @PrimaryKey(autoIncrement = true)
        @Column(name = "_id")
        private int id;
    
        @Index(unique=true, name="uname")
        private String uniqueName;
        //...
    }
    

    However, Orman generates the following DDL for this: Executing: CREATE TABLE IF NOT EXISTS node (uname TEXT NOT NULL, _id INTEGER PRIMARY KEY AUTOINCREMENT)

    Expected DDL is the following: CREATE TABLE IF NOT EXISTS node (uname TEXT UNIQUE, _id INTEGER PRIMARY KEY AUTOINCREMENT)

    So, how do I set a column as UNIQUE but NULLable in SQLite (Android)?

    opened by curioustechizen 3
  • Delay database connections in DBMS adapters

    Delay database connections in DBMS adapters

    We should delay establishing connections to DBMSes (if necessary) until MappingSession.start() since it is a blocking task and should not run upon initialization of adapter (which is an org.orman.datasource.Database implementation).

    Enhancement 
    opened by ahmetb 3
  • Model entity update bug

    Model entity update bug

    When I execute update on model instance my application throws following exception:

    java.lang.NullPointerException at org.orman.mapper.Model.prepareUpdateQuery(Model.java:197) at org.orman.mapper.Model.update(Model.java:162)

    In my entity I use text field with as primary key which I manually fill before storing into database. Since method prepareUpdateQuery requires autoIncrement field it fails with NPE.

    @Entity(table = "sui") public class SUI extends Model { @PrimaryKey private String id;

    ... }

    In my opinion prepareUpdateQuery should check against @PrimaryKey annotation instead of autoincrement value.

    opened by lhanusiak 8
  • mysql can't set characterEncoding when connection?

    mysql can't set characterEncoding when connection?

    QueryExecutionContainerImpl.java

    conn = DriverManager.getConnection( "jdbc:mysql://" + this.settings.getHost() + ":" + this.settings.getPort() + "/" + this.settings.getDatabase(), props);

    there is no dufault characterEncoding ,and we can't do any customize?

    opened by gguava 0
  • Sqlite Double Mapping Problem

    Sqlite Double Mapping Problem

    I have entity with double datatype field. i insert number such as 17507321 and inserted correct but when retrieve value form database convert to 17507300

    Bug Critical 
    opened by mojtabakaviani 0
  • Class extending Model and another Class

    Class extending Model and another Class

    Hi.

    I have some class for example class A , and class B which extends A. I can't store both in DB because If I want that classes to be an Entity, they need to extend Model< A> and Model< B>.

    Is there any solution?

    Enhancement Idea 
    opened by Antpachon 1
  • problem mapping entities on android project

    problem mapping entities on android project

    I don't know if this is the right place for this... I'm trying to create a simple android project using orman but can't get my entities mapped. I have all my entities under the "br.com.jera.shoplist.model" package and when i try to start the session i get this error:

    org.orman.mapper.exception.AnnotatedClassNotFoundInPackageException: Could not find any entity marked class in "br.com.jera.shoplist.model"
    

    Before anybody asks, all my entities have the @Entity annotation. I'm using this in my activty to start the session:

    //database
    Database db = new SQLiteAndroid(getApplicationContext(), "shoplist.db");
    MappingSession.getConfiguration().setCreationPolicy(SchemaCreationPolicy.CREATE);
    MappingSession.registerPackage("br.com.jera.shoplist.model");
    MappingSession.registerDatabase(db);
    MappingSession.start();
    

    Any idea? am I missing something?

    Bug 
    opened by beirigo 20
Owner
Ahmet Alp Balkan
Senior software engineer at Google Cloud, on cloud-native technologies: Kubernetes/GKE and Cloud Run.
Ahmet Alp Balkan
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
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
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
A MySQL connector wrapper that supports mapping to Kotlin classes.

Racoon Racoon is a wrapper for the MySQL connector. It makes communicating with the database easier by providing a bunch of functionalities: Mapping q

null 1 Jun 3, 2022
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.

Thanks to JetBrains for support Kripton Persistence Library project! Kripton Persistence Library Kripton is a java library, for Android platform, that

xcesco 117 Nov 11, 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
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
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
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
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
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
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

Yahoo 1.3k Dec 26, 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
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
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
Android SQLite API based on SQLCipher

Download Source and Binaries The latest AAR binary package information can be here, the source can be found here. Compatibility SQLCipher for Android

SQLCipher 2.6k Dec 31, 2022