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.


当前回答

我喜欢ActiveAndroid。它似乎是专门为Android编写的。这对我来说是个加分项。

我有一些Ruby on Rails的经验,如果你喜欢ActiveRecord的Rails方式,你可以很快地使用这个库。

https://www.activeandroid.com/

其他回答

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

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

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

还有一个新来者:android-active-record。 它是一个非常轻量级且易于使用的持久性框架,支持SQLite http://code.google.com/p/android-active-record/

我想在这里加上0.02美元关于我的ORMLite包。

它是Hibernate的轻量级替代品,并使用原生Android OS数据库调用来支持Android上的SQLite。它还支持在其他体系结构上使用JDBC的许多其他数据库类型。我们有一个针对ormite问题的Android邮件列表。

有db4o的负面经验(第8节):索引不能正常工作(异常等)。所以我没有设法避免在对象结构中有对象时在外部表中创建重复。更详细的解释在我的问题。希望有一天会好起来。

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