Android的ORMLite,通过序列化对象查询 [英] Android ORMLite, query by Serializable object

查看:419
本文介绍了Android的ORMLite,通过序列化对象查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用ORMLite,现在已经得到了,我不能回答的问题。看看我的例子:
我有类implementes序列化。

 上课时间实现Serializable {私人时间长;布拉布拉...}

和类操作,包括时间

 类操作实现Serializable {私人时间的时间;布拉布拉...}

操作数据库表,但不及时。因为我认为时间存储在数据库中的字节数组,因为它是序列化的对象。现在的问题是不是使用像EQ(ORMLite查询),(间)等这样的:

  OperationDao.queryBuilder(),其中()之间(time_field,timeObject1,timeObject2)。

我感兴趣的是:它是如何工作的?我可以这样做,以及如何查询?或者是不可能的,因为时间是字节数组,并且不能用于查询?

感谢好的答案。


解决方案

  

问题是它的使用权ORMLite像EQ(查询),(间)等这样的...


简短的回答是否定的,你不能查询存储在数据库中序列化字段。我会建议,而不是使用乔达的DateTime 的形式存储在数据库中作为。您将需要指定 @DatabaseField(dataType的DATE_TIME =),因为ORMLite可与的DateTime 使用反射。请参阅 DateTimeType

I use ORMLite and now have got a question that I can not answer. Look at my example : I have class implementes Serializable.

class Time implements Serializable {

private long time;

...blabla

}

and class Operation that includes Time

class Operation implements Serializable {

private Time time;

...blabla

}

Operation is a database table but Time not. As I think Time stored in database as byte array because it is Serializable Object. The question is it right to use ORMLite query like eq(), between() and other like that :

OperationDao.queryBuilder().where().between("time_field", timeObject1, timeObject2);

I am interested in : How does it work? Can I do queries like this and how? Or it is impossible, because Time is byte array and can not be used for query?

Thanks for good answers.

解决方案

The question is it right to use ORMLite query like eq(), between() and other like that ...

The short answer is no, you can't query for fields that are stored in the database as Serializable. I would recommend instead to use a Joda DateTime which gets stored in the database as a long. You will need to specify the @DatabaseField(dataType = DATE_TIME) because ORMLite works with DateTime using reflection. See the DateTimeType.

这篇关于Android的ORMLite,通过序列化对象查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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