本文介绍了ORMLite哪里clausule在字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用ormlite和我有一个领域的DB:

I use ormlite and I have a db with a field:

public static final String NAME = "name"; 
@DatabaseField (canBeNull = false, dataType = DataType.SERIALIZABLE, columnName = NAME)
private String[] name = new String[2];

和我想获得这个名字[0]和name [1]是车的元素。我尝试添加一个where clausule这样的:

And I would like to get all elements that name[0] and name[1] are "car". I try to add a where clausule like:

NAMEDB nameDB = null;
Dao<NAMEDB, Integer> daoName = this.getHelper().getDao(NAMEDB.class);
QueryBuilder<NAMEDB, Integer> queryName = daoName.queryBuilder();
Where<NAMEDB, Integer> where = queryName.where();
where.in(nameDb.NAME, "car");

不过,这并不工作,因为它是一个数组的字符串。

But it doesn't work because it's an array string.

我有其他领域:

public static final String MARK = "mark";

@DatabaseField (canBeNull = false, foreign = true, index = true, columnName = MARK)
private String mark = null;

和我可以这样做:

whereArticulo.in(nameDB.MARK, "aaa");

我怎样才能解决我的问题?谢谢你。

How can I solve my problem? Thanks.

推荐答案

ORMLite 做的支持查询属于类型字段 SERIALIZABLE 。它是存储阵列作为一个序列化字节[] ,所以你不能对查询的值与查询:

Unfortunately ORMLite does not support querying fields that are the type SERIALIZABLE. It is storing the array as a serialized byte[] so you cannot query against the values with an IN query like:

where.in(nameDb.NAME, "car");

ORMLite不支持外集合,但你必须自己与其他类持有名设置。见样品code中的文档:

ORMLite does support foreign collections but you have to set it up yourself with another class holding the names. See the documentation with sample code:

这篇关于ORMLite哪里clausule在字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 03:31