I think, therefore I blog

Android ORM / JPA

By , 19 December 2011

Android ORM / JPA
Android ORM / JPA

Coming from the server-side, I find it hard to live without ORM (Object-Relational Mapping) such as JPA. Now that I've started writing Android Apps, I set about finding a JPA ORM tool for Android.

Here is a comparison of the tools I found that do ORM and are lightweight enough for use with Android.

  Annotations DB Ops Size License Docs Age
OrmLite JPA or custom DAO or Entity 200kb Open docs 1yr
ORMAN JPA-like Entity 170kb Apache2 wiki 2yrs
greenDAO N/A Codegen DAO or Entity <100kb Apache2 docs  
ActiveAndroid JPA-like Entity   $20 wiki  
AndrORM None       docs 1yr

"DB Ops" refers to how database operations such as persist() and update() are handled. Normally either by a DAO (data access object) or by the entity themselves.

Handling Large Data Sets

Performance counts - especially since I need to handle large data sets. I don't want to load 3000 records into memory at once when the device only has room to display 10 at a time. Native Android supplies a Cursor to interate large data sets, and some ORM tools provide their own method too.

greenDAO has Query.lazyList() and OrmLite has DAO.iterator(Query) to do this, however Android adapters do not bind to an iterator so a custom adapter would need to be written in any case. There is a thread online that discusses this, however I think I can rig up a something similar to my LazyList for JPA to make this happen.


I've started my project with OrmLite because it is the most mature. Lazy loading query results will need some custom code, but in the long run I think it will be better than polluting my code with column names and SQL hacks.

greenDAO was a good candidate from the performance perspective, but really I want to write my Entities myself so I can add the methods that I need.

Android ORM / JPA

About Roger Keays

Android ORM / JPA

Roger Keays is an artist, an engineer, and a student of life. Since he left Australia in 2009, he has been living as a digital nomad in over 40 different countries around the world. Roger is addicted to surfing. His other interests are music, psychology, languages, and finding good food. Click here to subscribe to his weekly blog, or stalk him on Facebook and Twitter.

Comment posted by: , 4 years ago

Jeff, the JPA annotations didn't have very good coverage of the ORMlite mappings and features and didn't offer much advantage over the native annotations so I used the native annotations.

Comment posted by: Jeff Bethune, 4 years ago

 Were you able to get the JPA annotations working with Ormlite on Android?  Or did you go with the ormlite annotations?

Comment posted by: , 4 years ago

Hi Phil. OrmLite is better documented than Androrm and seems to have a bigger community. That's all.

Comment posted by: Phil, 4 years ago

 Hey, what was the reason to decide against androrm? I'm the developer and very interested in any feedback, that could help me to improve androrm. By the way it is licensed under the MIT License. See androrm.com/download/license

Comment posted by: Sven Meier, 4 years ago

<shameless plug>

Take a look at:


Age < 1 month, but it cursor-backed queries can easily be used with listviews.

</shameless plug>

Join Over 1000 Subscribers

I write every Sunday about travel, psychology, and technology. Thousands of people just like you have already subscribed—and for good reason. It'll change your life. And it's free :)

Read a Good Book

“A spellbinding true story of love, passion and adventure. One can’t help but be swept away by 100% Love Guaranteed.” —Dr Tammie Matson, author of Elephant Dance.

Chat For A While

Your Vote Matters

Which animal will take over when humans go extinct?