问题
select from comments.Comment
where ownerType == 'looks.Look'
AND ownerName == 'Yakuza' order by date
I get exception:
Portion of expression could not be parsed: AND ownerName == 'Yakuza'
While this query works nice:
select from comments.Comment
where ownerType == 'looks.Look'
order by date
And this too:
select from comments.Comment
where ownerName == 'Yakuza' order by date
The full code:
PersistenceManager pm = PMF.get().getPersistenceManager();
String query = "... query goes here ...";
List<Comment> comments = null;
try {
comments = (List<Comment>) pm.newQuery(query).execute();
}
...
回答1:
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();
}
来源:https://stackoverflow.com/questions/4903474/gql-error-on-where