WHERE上的GQL错误 [英] GQL error on WHERE
本文介绍了WHERE上的GQL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
select from comments.Comment
where ownerType == 'looks.Look'
AND ownerName == 'Yakuza' order by date
我得到异常:
Portion of expression could not be parsed: AND ownerName == 'Yakuza'
此查询很好用:
select from comments.Comment
where ownerType == 'looks.Look'
order by date
这也是:
select from comments.Comment
where ownerName == 'Yakuza' order by date
完整代码:
PersistenceManager pm = PMF.get().getPersistenceManager();
String query = "... query goes here ...";
List<Comment> comments = null;
try {
comments = (List<Comment>) pm.newQuery(query).execute();
}
...
推荐答案
将"AND"替换为&&"
Replace "AND" with "&&"
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
Query query = pm.newQuery("select from " + Song.class.getName()
+ " where mArtist== '" +artist+
"' && mTitle=='"+title+
"' && mAlbum=='"+album+"'" );
List<Song> list = (List<Song>) query.execute();
} catch (RuntimeException e) {
System.out.println(e);
throw e;
} finally {
pm.close();
}
这篇关于WHERE上的GQL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文