GQL error on WHERE

701 views Asked by At
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

There are 1 answers

0
Win Myo Htet On BEST ANSWER

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();
  }