1
我想知道如何在連接到應用程序引擎的Android客戶端執行RPC調用時防止重複的插入。下面是我的代碼和我在後端嘗試的內容,但是當我這樣做時,我得到一個「內部服務器錯誤」。防止在Android連接的appengine中使用jdo的重複表插入
public void createentity(userentity e) {
PersistenceManager pm = PMF.get().getPersistenceManager();
//to go through the records and and check for duplicates
Query q = pm.newQuery("select from" + userentity.class + "where Country=='" + e.getCCNumber() + "'");
List <userentity> s = (List <userentity>) q.execute();
//if the size is equal to to null means there is no duplicate
if (s.size() == 0) {
//insert the value
try {
pm.makePersistent(e);
} finally {
pm.close();
}
}
}
@SachinD當編輯後,請確保您修復後整體,包括代碼格式化(http://jsbeautifier.com可以在許多情況下使用),去除問候/簽名和去除有趣的話。 – 2012-03-18 09:22:57
@ SachinaD..ok謝謝 – 2012-03-18 09:24:44
當您回覆其他評論時,請回復正確的名稱;)在這種情況下,請使用'@ Rob'或'@ RobW'。有關詳情,請參閱[Meta:評論回覆如何工作](http://meta.stackexchange.com/questions/43019/how-do-comment-replies-work)。 *我回復了前一位編輯的帖子,教他如何編輯。* – 2012-03-18 09:28:27