291

Anyone working on the Android ('gPhone') have or know of a place where I can find a good ORM tool for it? The code is written in Java, and the database is SQLite. What I would like to find is a tool that given the object definition, can auto-generate the tables and the CRUD functions (that would be awesome), or, barring that, a tool that can take the table definition, the object definition, and auto-generate the CRUD functionality. The rub is that all of this must happen within the Android framework, which has its own conventions as to how database access works.

JJD
52.8k63 gold badges218 silver badges352 bronze badges
asked Dec 16, 2008 at 14:47
5
  • I don't think there are any available now. Commented Feb 17, 2009 at 10:36
  • 2
    its 2014. I thought I will mention Sprinkles (github.com/emilsjolander/sprinkles) since no one has mentioned it.. 500 stars on github, on meaven central, content observers, worth checking Commented Apr 10, 2014 at 12:43
  • It's 2015. Software Tree has recently released JDXA, a simple yet powerful, and flexible ORM for Android. Supports inheritance, one to one, one to many, many to one, and many to many relationships. JDXA's POJO (Plain Old Java Objects) friendly non-intrusive programming model does not require you to change your Java classes in any way: - No need to subclass your domain classes from any base class - No need to clutter your source code with annotations - No need for DAO classes - No source code generation Commented Sep 30, 2015 at 1:12
  • Check out this nice tutorial on JDXA ORM . Commented Nov 13, 2015 at 22:35
  • If you prefer plain natural Android code without additional library dependencies take a look at the SQLite peer class code generator example. It is annotation based and supports combined primary keys, combined unique constraints and indexing. Commented Apr 27, 2017 at 8:48

15 Answers 15

112

Thought I'd just add my 0ドル.02 here about my ORMLite package.

It is a lightweight replacement to Hibernate and uses native Android OS database calls to support SQLite on Android. It also supports many other database types using JDBC on other architectures. We have an Android mailing list for ORMLite questions.

answered Jun 25, 2010 at 18:04
Sign up to request clarification or add additional context in comments.

7 Comments

Does ORMLite have built-in support for (one|many)-to-(many|one) relationships? I can't find much info on that ... If not, are there plans for this?
Depends on what you mean by "support". There is some example code on how to use "foreign objects" which are how you to one-to-many and there are examples on how to use join tables to accomplish many-to-many (ormlite.com/docs/examples). Post to the user list with more questions (groups.google.com/group/ormlite-user).
Yeah, it is certainly larger than ActiveAndroid. A lot more functionality as well of course. Also freeware as opposed to AA's license. But if size is the goal, ORMLite is not for you.
@Gray Ironic since it's supposed to be "Lite" :P
Indeed @SalmanPK. Although there are varying degrees of lite. :-)
|
67

This question cannot age but the suggested frameworks can. So, here is first a list of what I find important in such frameworks for comparison:

  • Is there a Maven or Gradle artifact? (that's a big plus depending on whether you use maven or gradle, obviously)
  • Is the code accessible in an easy way including a fast overview on commits to judge the activity? (code hosted on github is a definite plus for me, in that matter)
  • Release management: are there releases/release tags and artifacts for it? (there are some that are hosted on github and require either git clone or offer the master tarball for download - for me a big minus if not even release tags are set and addressed in the README)
  • as size matters I put up some hints where it was easy to get by (I did not download anything, so from those projects that offer no release artifacts there are no sizes)

And here is a list of frameworks with notes on the points above. I looked up some more like aBatis and Hadi but I added only those that had some activity after 2011.

I have not tried any of those but maybe I can spare current readers a bit of time by listing the nowadays active projects. Please add a comment if you know of other projects that satisfy some of the above points and have some serious development (over some time) going on.

EDIT (2013 Nov): updated the list to the current status of the projects. Some of these have added release tags to their github repos as well as Maven/Gradle support. Good work!

EDIT (2015 Apr): updated the list, added Sprinkles (as per comment by @AndroidGecko) and Realm.io.

answered Feb 18, 2013 at 17:29

1 Comment

I strongly recommend to use Realm, it´s really fast and fluid to work!
40

If performance and code size matter, check out greenDAO. I'm the author of it, and my motivation to create another ORM was to avoid reflection in the hotspots. It turned out that greenDAO can be up to 4 times faster than ORMLite. Checkout the feature page for details.

answered Oct 24, 2011 at 9:11

15 Comments

Looks quite good, but having to generate the Dao's is a turnoff for me :(
Yes, generating code is an additional step for developers, but it saves you a great deal of performance in the app. Both bootstrapping and parsing database results are significantly faster. Other tools rely on reflection, which is cruelly slow in Android.
I'm using greenDao in my projects, and I'm very pleased with it.
@greenrobot do you have some showcases of "big apps" using your lib?
@StErMi Path is using greenDAO. They have >1 M installs. See github.com/greenrobot/greenDAO/issues/20#issuecomment-13278922
|
10

I don't know of anything that is exactly what you are asking for, but there is an alternative to SQLite that you may find useful if your architecture requirements are flexible. It may be worth checking out db4o:

JJD
52.8k63 gold badges218 silver badges352 bronze badges
answered Feb 17, 2009 at 21:10

2 Comments

i had good results with DB40... wanna checkout Active Android though...
activeandroid.com looks cool, I'm looking forward to giving it a spin
9

ActiveAndroid (削除) (20ドル) (削除ここまで) looks like it may be exactly what you need.

answered May 3, 2010 at 21:00

3 Comments

I know you're not trying anything shifty here, but can you please disclose your affiliation in your posts when you mention one of your own products on SO? I know your name is in the footer of the linked page, but we're trying to crack down on astroturfing (which this is not), so we're asking everyone to follow the same disclosure guidelines. Thanks.
Just a heads up, ActiveAndroid is not free.
ActiveAndroid is now free and open-source - pardom.github.com/ActiveAndroid
7

I liked ActiveAndroid. It's written specifically for Android it seems. That's feels like a plus to me.

I have some Ruby on Rails experience and if you like the Rails way of ActiveRecord you can very quickly get moving with this library.

https://www.activeandroid.com/

answered Oct 20, 2010 at 12:46

3 Comments

Nice framework, but it conflicts with org.codehous.jackson library, so if you use it in your project you wil be unable to use ActveAndroid
How does it conflict? Did you report it as a bug in tracker.activeandroid.com?
Maybe have a look at androrm.the-pixelpla.net it has most of the features and i would say even some more. Plus: it is free and open source.
6

https://github.com/ahmetalpbalkan/orman

Orman framework might help you. It is especially designed for that and very small and useful.

answered Jul 15, 2011 at 21:40

Comments

6

I'm also looking for an ORM on Android. I tested ActiveAndroid, NeoDatis and db4o, and I think that I'll use one of the two last.

NeoDatis and db4o are really similar, so I would like some advice to choose the best one. Is someone using one of them on his project ? I'll use it for free and paid app, but it seems that the two haven't any license limitation for Android.

There is a benchmark here that seems to say that NeoDatis is faster than db4o, but I don't know if we can base my opinion on this.

JJD
52.8k63 gold badges218 silver badges352 bronze badges
answered Sep 9, 2010 at 16:00

2 Comments

Db40 and NeoDatis are object databases, just size of these is totally prohibitive to be of any use on Android
@ DroidIn.net could you provide a link that sustains your comment ?
3

One more newcomer: android-active-record. It's very lightweight and easy for use persistence framework for Android backed by SQLite http://code.google.com/p/android-active-record/

answered Nov 18, 2010 at 5:57

2 Comments

Looks like its still in early development, but worth keeping an eye on!
Tried it - it's nice beginning but needs a lot of work to be ready for the prime time
2

ActiveRecordJS from Aptana is a Javascript ORM that should run on the gPhone. It is designed to work with Jaxer and Gears. When you user the Jaxer Adapters, you can connect to SQLLite.

UPDATE: I don't think I made it clear, but ActiveRecordJS is an ORM that runs client side, which could be an advantage to you on the gPhone.

answered Feb 15, 2009 at 17:52

2 Comments

In Java code? Or in JavaScript code?
I'm pretty sure what you're talking about is a Javascript solution intended purely for browser-based (Web) applications. I don't see how it relates to native app development for Android.
2

http://hadi.sourceforge.net

This tool is very simple and easy to use.

answered Sep 8, 2011 at 7:43

Comments

1

I have developed my own implementation of the JPA ORM for Android. It is not yet fully feature complete, but you can annotate class with the @Entity, @Id, @Column annotations and you get JPA entities that can be stored and retrieved from the SQLite database. It needs some more features & cleanup before I'll post it to the public, but if there is enough interest it might accelerate my effort.

answered Feb 10, 2010 at 18:07

2 Comments

Sounds interesting, do you have already s.th. to have a look at / to try? Cheers, Martin
More than a year later, how is the progress on this? JPA + Annotations on Android sounds GREAT!
1

Even though this is an old post, the topic is still relevant. Hence, I want to share an interesting article and nice approach to solving most of the issues mentioned in the question:

http://blog.codecentric.de/en/2011/04/android-persistence-accelerated-small-inhouse-orm/

Hope anyone finds this as useful as myself!

answered Nov 30, 2011 at 21:10

Comments

1

My own DroidParts /http://droidparts.org/ just reached v0.5. It's a DI/ORM library & more.
Not much documentation, but includes a sample app.

answered May 19, 2012 at 9:52

1 Comment

May be adding proper documentation is a good idea.
0

Had negative experience with db4o (v. 8): indexing didn't work properly (exception etc.). So I didn't managed how to avoid creating duplicates in foreign tables when having object in object structure. More detailed explanation in my question. Hope one day it would be better.

answered Sep 13, 2011 at 14:54

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.