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;
}
![在这里输入的形象描述] [2]
添加一段代码以显示查询。请注意,整个应用程序在我的DEV PC中运行良好。 – lonelyloner
我认为您可以通过调试生产应用程序来确定您要找的电子邮件是否正确?这个简单的错误是最难纠正的:/ –