为 Android 项目选择 ORM(最低 API 级别 7) [英] Choosing an ORM for Android project (min. API level 7)

查看:27
本文介绍了为 Android 项目选择 ORM(最低 API 级别 7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个应用程序,它的主要性能问题是使用由 JSON 响应组成的基于文件的数据库.

I currently have an application, where it's primary performance issue is using file-based database consisted of JSON responses.

我想重写我的应用程序以使用 SQLite 数据库功能.
由于我很懒,所以我想使用某种ORM.

I'd like to rewrite my application to use SQLite database feature.
Since I'm lazy, I'd like to use some kind of ORM.

到目前为止,我只发现了两个大型 ORM 库:

So far I have found only two big ORM libraries:

我的主要目标是尽可能提高处理数据的性能

但我发现这些库存在两个可能的问题.

But I've found two possible issues with those libraries.

GreenDAO 正在使用某种代码生成器,这会减慢我的开发速度,因为我必须编写生成器,然后使用生成的代码.我不太喜欢这个主意.

GreenDAO is using some kind of code generator, and that would slow me down on development as I would have to write generator, and then use generated code. And I don't very like this idea.

DB4O 是 JPA,我一直认为它缓慢且占用大量内存,因此不适合低端设备(请记住 Android API v7)

DB4O is JPA, which I've always considered as slow and heavy on memory usage, therefore unsuitable for low-end devices (remember the Android API v7)

广告@ChenKinnrot:
估计的负载应该足以考虑使用 ORM.
就我而言,它是大约 25-30 个唯一表,以及至少 10 个表连接(一次 2-4 个表).大约 300-500 个唯一字段(列)

所以我的问题是:

  1. 我应该在 Android 应用程序中使用 ORM/JPA 层吗?
  2. 如果是这样,你会推荐我使用什么库?(也请添加一些参数)
  1. Should I use ORM/JPA layer in Android application?
  2. If so, what library would you recommend me to use? (and please add some arguments too)

推荐答案

我用过 ORMLite,一旦你掌握了它的窍门(几个小时),我发现它很简单,非常强大,并且不会导致任何性能问题(应用在 Gingerbread 上在 HTC 欲望和 HTC Hero 上测试).

I've used ORMLite and found it straightforward once you got the hang of it (a few hours), quite powerful and didn't cause any performance problems (app tested in Gingerbread on HTC desire and HTC Hero).

我将在任何需要使用数据库的项目中再次使用它.

I will be using it again in any projects I need to use a DB for.

这篇关于为 Android 项目选择 ORM(最低 API 级别 7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆