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.


当前回答

我自己的DroidParts /http://droidparts.org/刚刚发布了0.5版。它是一个DI/ORM库等等。 没有太多的文档,但是包含了一个示例应用程序。

其他回答

来自Aptana的ActiveRecordJS是一个可以在gPhone上运行的Javascript ORM。它被设计用于Jaxer和Gears。当您使用Jaxer适配器时,您可以连接到SQLLite。

更新:我不认为我说清楚了,但ActiveRecordJS是一个运行客户端的ORM,这可能是你在gPhone上的一个优势。

我自己的DroidParts /http://droidparts.org/刚刚发布了0.5版。它是一个DI/ORM库等等。 没有太多的文档,但是包含了一个示例应用程序。

我也在寻找Android上的ORM。我测试了ActiveAndroid, NeoDatis和db4o,我想我将使用最后两个中的一个。

NeoDatis和db4o非常相似,所以我想要一些建议来选择最好的一个。有人在他的项目中使用了其中之一吗?我将在免费和付费应用中使用它,但似乎这两款应用在Android上没有任何许可限制。

这里有一个基准测试,似乎说NeoDatis比db4o更快,但我不知道我们是否可以基于这一点得出我的观点。

这个问题不会变老,但建议的框架会变老。因此,这里首先列出了我在这类框架中发现的重要内容,以便进行比较:

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)

这里是一个框架的列表,并对以上几点进行了说明。我查找了一些像aBatis和Hadi这样的,但我只添加了2011年之后有一些活动的人。

http://ormlite.com, Maven artifact, 52 kB, SVN, the website is... difficult but there seem to be a lot of examples, according to http://ormlite.com/changelog.txt the last version is 4.48 from 2013, https://github.com/j256/ormlite-core (release tags), last activity March 2015 http://greendao-orm.com, good maintenance, Maven artifact, focus: fast performance, small size, little RAM consumption. Github: https://github.com/greenrobot/greenDAO/ (release tags, > 2300 stars), last activity November 2014 https://github.com/roscopeco/ormdroid, small size, last activity August 2014 http://www.activeandroid.com, https://github.com/pardom/ActiveAndroid (> 2300 stars), good maintenance, community, no release tags (download points to master tarball), Maven artifact, last activity October 2014 http://droidparts.org, https://github.com/yanchenko/droidparts (release tags, > 600 stars), also dependency injection, Maven artifact, actively maintained http://www.androrm.com , https://github.com/androrm/androrm (release tags), last activity Jan 02, 2014 (github) https://github.com/emilsjolander/sprinkles (release tags, > 600 stars), last activity May 2014, Maven artifact (thanks @AndroidGecko) http://realm.io, https://github.com/realm/realm-java replaces not only ORM but also SQLite, also for iOS (release tags, > 1600 stars), actively maintained, own Maven repository

我没有尝试过其中的任何一个,但也许我可以通过列出目前活跃的项目来节省当前读者的时间。如果你知道其他项目满足以上的一些要求,并且已经有了一些重要的开发(经过一段时间),请添加评论。

EDIT(2013年11月):更新列表到项目的当前状态。其中一些已经添加了发布标签到他们的github回购以及Maven/Gradle支持。干得好!

EDIT(2015年4月):更新列表,添加了Sprinkles(根据@AndroidGecko的评论)和Realm.io。

如果性能和代码大小很重要,请查看greenDAO。我是它的作者,我创建另一个ORM的动机是避免在热点中反射。结果表明,greenDAO的速度比ORMLite快4倍。有关详细信息,请查看功能页面。