Android的ORMLite,通过序列化对象查询 [英] Android ORMLite, query by Serializable object
问题描述
我用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 JodaDateTime
which gets stored in the database as along
. You will need to specify the@DatabaseField(dataType = DATE_TIME)
because ORMLite works withDateTime
using reflection. See the DateTimeType.这篇关于Android的ORMLite,通过序列化对象查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!