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.
当前回答
https://github.com/ahmetalpbalkan/orman
Orman框架可能会帮助您。它是专门为此设计的,非常小巧实用。
其他回答
我不知道你到底想要什么,但是如果你的体系结构需求是灵活的,有一个替代SQLite的选择,你可能会发现它很有用。db4o可能值得一试:
Android 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。
我已经为Android开发了我自己的JPA ORM实现。它还没有完全完成功能,但是您可以使用@Entity、@Id、@Column注释注释类,并且您可以获得可以从SQLite数据库存储和检索的JPA实体。在我将它发布到公众之前,它需要更多的功能和清理,但如果有足够的兴趣,它可能会加速我的努力。
我也在寻找Android上的ORM。我测试了ActiveAndroid, NeoDatis和db4o,我想我将使用最后两个中的一个。
NeoDatis和db4o非常相似,所以我想要一些建议来选择最好的一个。有人在他的项目中使用了其中之一吗?我将在免费和付费应用中使用它,但似乎这两款应用在Android上没有任何许可限制。
这里有一个基准测试,似乎说NeoDatis比db4o更快,但我不知道我们是否可以基于这一点得出我的观点。
https://github.com/ahmetalpbalkan/orman
Orman框架可能会帮助您。它是专门为此设计的,非常小巧实用。
推荐文章
- Manifest合并失败:uses-sdk:minSdkVersion 14
- 到底是什么导致了堆栈溢出错误?
- 为什么Android工作室说“等待调试器”如果我不调试?
- Java:路径vs文件
- 如何检查我的EditText字段是否为空?
- Android从图库中选择图像
- 后台任务,进度对话框,方向改变-有任何100%工作的解决方案吗?
- ExecutorService,如何等待所有任务完成
- Android:垂直对齐多行EditText(文本区域)
- Maven依赖Servlet 3.0 API?
- Android无尽列表
- 如何在IntelliJ IDEA中添加目录到应用程序运行概要文件中的类路径?
- getter和setter是糟糕的设计吗?相互矛盾的建议
- Android room persistent: AppDatabase_Impl不存在
- Java的String[]在Kotlin中等价于什么?