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库等等。 没有太多的文档,但是包含了一个示例应用程序。
其他回答
我已经为Android开发了我自己的JPA ORM实现。它还没有完全完成功能,但是您可以使用@Entity、@Id、@Column注释注释类,并且您可以获得可以从SQLite数据库存储和检索的JPA实体。在我将它发布到公众之前,它需要更多的功能和清理,但如果有足够的兴趣,它可能会加速我的努力。
来自Aptana的ActiveRecordJS是一个可以在gPhone上运行的Javascript ORM。它被设计用于Jaxer和Gears。当您使用Jaxer适配器时,您可以连接到SQLLite。
更新:我不认为我说清楚了,但ActiveRecordJS是一个运行客户端的ORM,这可能是你在gPhone上的一个优势。
ActiveAndroid(20美元)看起来可能正是你所需要的。
有db4o的负面经验(第8节):索引不能正常工作(异常等)。所以我没有设法避免在对象结构中有对象时在外部表中创建重复。更详细的解释在我的问题。希望有一天会好起来。
这个问题不会变老,但建议的框架会变老。因此,这里首先列出了我在这类框架中发现的重要内容,以便进行比较:
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。
推荐文章
- 何时在Android中使用RxJava,何时使用Android架构组件中的LiveData ?
- 如何在Android项目中使用ThreeTenABP
- 指定的子节点已经有一个父节点。你必须先在子对象的父对象上调用removeView() (Android)
- 我的Android设备没有出现在adb设备列表中
- 在没有安装apk的情况下获取Android .apk文件的VersionName或VersionCode
- Fragment onResume() & onPause()不会在backstack上被调用
- 如何设置基线对齐为假提高性能在线性布局?
- 如何检索插入id后插入行在SQLite使用Python?
- 对于一个布尔字段,它的getter/setter的命名约定是什么?
- 如何获得当前屏幕方向?
- 如何在Android中渲染PDF文件
- 什么是ORM,它是如何工作的,我应该如何使用它?
- 如何计算一个元素在列表中出现的次数
- c++中类似于java的instanceof
- 我如何解决错误“minCompileSdk(31)指定在一个依赖的AAR元数据”在本机Java或Kotlin?