我已經使用了像這裏的javax.jdo.Query JDO for Google App Engine: escaping quotes。然而,我的單引號(')查詢字符串不斷爆炸。appengine數據存儲查詢轉義單引號(')
Query query = pm.newQuery("select from " + Book.class.getName() + " where mArtist== '"+ artist + "' && mTitle=='" + title + "'");
這裏是例外
javax.jdo.JDOUserException: Portion of expression could not be parsed: 't Give Up'
org.datanucleus.store.query.QueryCompilerSyntaxException: Portion of expression could not be parsed: 't Give Up'
下面是這個query.toString()
SELECT FROM com.example.Book WHERE mArtist== 'Famous Writer' && mTitle=='We Won''t Give Up'
葉,我甚至躲過了單引號('),每雙單引號appengine文檔
你說的 「爆炸」 呢?究竟發生了什麼? – 2012-03-04 03:55:09
對不起。變得有點戲劇性,並忘記了異常觸發。我已經用Exception更新了這篇文章。 – 2012-03-04 04:38:15