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();
}
...
答案 0 :(得分:2)
将“AND”替换为“&amp;&amp;”
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();
}