Green DAO vs ORM lite vs Active Android [closed]
Asked Answered
K

3

60

Which is the best ORM tool available for Android?

I am seeing ORMlite and ActiveAndroid are the most discussed across and a friend of mine suggested me to use GreenDAO. So looking for some knowledge resource which can help me in Decision Making?

Features I am looking to judge are freely available (open source), good documentation, active forums, stable version available, etc, which ever required for developer.

Kylix answered 3/12, 2012 at 10:6 Comment(4)
GreenDao is simple to use but it has its limit, for Ex. One cannot configure the cache, contrary to ORMLite's cache and is not a "Real" ORM. I'll explain my answer, in ORMLite you can configure the cache in some manner that queries might not need to access the database, in GreenDao it's not possible and every query pointed to the databaseTorbernite
thank you for asking this questionPop
Another factor to think about is Android architecture. ORMLite makes you extend an activity, which may not work with some architectures.Wallet
@stevebot, no, I don't need to extend an Activity when you use ORMLiteTangier
M
23

I would suggest ORMlite its open source freeware & has good documentation also it support java as well as android.

It has good developer support & many application running on ORMlite (Including I have developed :) ).

check this comparison of ORMLite & Green DAO for your referance.

Macegan answered 3/12, 2012 at 11:28 Comment(7)
Thanks for responding, but in that comparison I don't see any major difference ORMLite and GreenDAO. I am able to find GreenDAO performs better, but ORMLite is popular. Still trying to know which makes ORMLite more popular than the one which performs well.Kylix
Adding links to support above comments #11538061 greendao-orm.com/featuresKylix
Regarding the comparison... I don't understand the use of JAR file size as a measure of library 'weight'. One library might have lots of extra optional functionality that gets stripped out in most projects. I think it would be necessary to build a basic project of each and check APK size deltas for release builds.Wisp
Is there also a benchmark comparison of other libraries, like SugarOrm ?Manzanares
I found this post a year or two ago while looking for a good ORM for Android, and this lead me to use ORMLite for a time, which I regret. ORMLite just really isn't written well for Android though. If you look at benchmarks it is several orders of magnitude slower than other ORMs like GreenDAO even on the latest Android OS. This is because ORMLite heavily relies on reflection for everything, and is so slow because it creates so many objects that need to be GC'd. GC in Android = laggy UI. I'd recommend investing time in a different ORM.Reward
I am curious about how the comparison changes with ART. @Reward mentioned GC time, and that is the whole point of the ART runtime. Anyone who knows/will do a benchmark?Nerty
@domenicop I imagine the tests won't have as drastic a difference on ART, but for a few more years most users still won't be on ART, I'd argue GreenDAO is still your best bet. Don't get me wrong, GreenDAO has disadvantages (not supporting enums, not supporting annotations. People have put in pull requests to add these features, but they still haven't merged them). Still, GreenDAO is fast, and pretty simple when you get right down to it. It's my go to DB for now and at least the next few years.Reward
W
11

A difference between ORMLite and GreenDAO is the usage of annotations. While ORMLite uses Annotations, GreenDAO does not, as described here.

Annotations used by ORMLite rely on reflection, which might impact performance especially on slower Android devices in a negative way. Would be interesting to see benchmarks comparing ORMLite and GreenDAO.

Wallaby answered 25/3, 2013 at 16:56 Comment(5)
ORMLite on Android can use a compile-time generated config file that avoids relying on reflection altogether during app usage. Using annotations is important to me as you can use existing model objects.Octad
Here you have a Github project that compares the performance of ORMLite and GreenDao to raw SQLite: github.com/littleinc/android-orm-benchmarkLampkin
Annotations DON'T rely on reflection. Libraries using Annotations MAY rely on reflection. AndroidAnnotations, Dagger 2, Retrofit, ButterKnife, LoganSquare, Gson, Wire, etc are examples of libraries using Annotation Processor, which generate boilerplate code at compile time, and don't use reflection at allWenona
The annotations used by ORMLite were meant in this case, not annotations in general. I will update the answer to make this more explicit.Wallaby
For people who got here via Google: This information is outdated, GreenDAO supports annotations since version 3 which was released in July 2016.Agape
W
5

One issue I have with a number of the libraries that I've used is that they require that their initialization take place in android.app.Application.onCreate(). I prefer that libraries allow me to do their initialization in a secondary thread, in a service, or after I have finished displaying the user interface.

I believe that Active Android has this 'problem', and ORMLite does not. I'm not sure about GreenDAO.

Whether it is really a problem depends on your application, but I will note that the docs for onCreate() say "Implementations should be as quick as possible (for example using lazy initialization of state) since the time spent in this function directly impacts the performance of starting the first activity, service, or receiver in a process."

Unrelated to that, I note that ActiveAndroid uses annotations, like ORMlite, but unlike GreenDAO which uses code generation.

Wisp answered 30/3, 2013 at 20:33 Comment(3)
Sugar ORM, considerably light, on the other hand does not pose this problem. You can do things from inside services if you want.Inveracity
JDXA ORM for Android gives the flexibility of initialization at anytime in your application life cycle. JDXA follows the KISS Principles of ORM. JDXA does not use annotations. It is totally non-intrusive to your domain object model - there is no need to subclass from any base class; no need for DAO classes.Nixie
@DamodarPeriwal I have to fill out a form to obtain it? No thank youRomanic

© 2022 - 2024 — McMap. All rights reserved.