问题描述
我是新来这个,请帮助我。
I am new to this, please help me.
我想使用ormlite像(列名,值)的功能,但是这不是为我工作。但是当我测试全文,它正在像EQ的功能。
I am trying to use ormlite like(column name,value) function, but this is not working for me. But when I test full text it is working like "eq" function.
我的code是,
try {
QueryBuilder<MakeDTO, Integer> qb = makeDao.queryBuilder();
qb.where().like("madeCompany", filterKey);
PreparedQuery<MakeDTO> pq = qb.prepare();
return makeDao.query(pq);
} catch (SQLException e) {
throw new AppException(e);
}
感谢。
推荐答案
这是老问题,但事情我只是解决了(ORMLite的文档并不清楚)。你需要为了告诉ORMLite,您的查询字符串的侧面可以匹配任何数目的字符换行查询参数%的。
An old question, but something I just solved (ORMLite's documentation isn't that clear). you need to wrap your query parameter in "%"'s in order to tell ORMLite which side of your query string can match any number of characters.
例如,如果你想查询匹配包含您的字符串中使用下列任何madeCompany:
For example, if you want your query to match any madeCompany that contains your string use the following:
try {
QueryBuilder<MakeDTO, Integer> qb = makeDao.queryBuilder();
qb.where().like("madeCompany", "%"+filterKey+"%");
PreparedQuery<MakeDTO> pq = qb.prepare();
return makeDao.query(pq);
} catch (SQLException e) {
throw new AppException(e);
}
这篇关于Android的ormlite像()函数不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!