2014-06-30 88 views
0

是「NAME =」爲用戶類定義如下什麼在谷歌App Engine的數據存儲鍵字段

@PersistenceCapable(detachable="true") 
public class User { 
    @PrimaryKey 
    @Persistent 
    private String email; 

    @Persistent 
    private String firstname; 

    @Persistent 
    private String lastname; 

在PROD,我增加了一個用戶與電子郵件=「[email protected]」 firstname = something,lastname =通過JDO的東西。然後在數據存儲查看器中,ID /名稱字段的值爲「[email protected]爲什麼添加「名稱=」?我的程序找不到key =「[email protected]」的用戶。它可以在我的DEV PC中,但從來沒有「Name =」。

[添加檢索用戶實例的源代碼]它在我的DEV PC中運行良好。

public static User getUser(String email){ 
    PersistenceManager pm = PMF.get().getPersistenceManager(); 
    User user, detached = null; 
    try { 
     user = pm.getObjectById(User.class, 
      email); 

     // If you're using transactions, you can call 
     // pm.setDetachAllOnCommit(true) before committing to automatically 
     // detach all objects without calls to detachCopy or detachCopyAll. 
     detached = pm.detachCopy(user); 
    } 
    catch(Exception e){ 
     e.printStackTrace(); 
    } 
    finally { 
     pm.close(); 
    } 
    return detached; 
} 

enter image description here

![在這裏輸入的形象描述] [2]

回答

0

由於ID可以是自動生成的編號或自定義字符串 「NAME =」 有沒有做它清除id是一個字符串(否則你會得到一個「id =」)。

至於找不到用戶,問題一定是查詢的方式,所以我們需要更深入的瞭解你的代碼。

+0

添加一段代碼以顯示查詢。請注意,整個應用程序在我的DEV PC中運行良好。 – lonelyloner

+0

我認爲您可以通過調試生產應用程序來確定您要找的電子郵件是否正確?這個簡單的錯誤是最難糾正的:/ –

相關問題