gpt4 book ai didi

java - 应用引擎(JAVA): Updating record

转载 作者:行者123 更新时间:2023-12-01 16:07:37 26 4
gpt4 key购买 nike

我有以下代码[在 doPost() 中]来编辑现有记录。它没有给出任何错误,但记录未保存。任何想法?或基于单个唯一字段更新现有记录的最佳方式是什么?

     if(sAction.compareToIgnoreCase("S")==0)
{

String email = req.getParameter("Email");

PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = pm.newQuery(SMSUser.class);
query.setFilter("Email == pEmail");
query.declareParameters("String pEmail");
List<SMSUser> users = (List<SMSUser>) query.execute(email);
if(!users.isEmpty())
{
Iterator it = users.iterator();
SMSUser u = (SMSUser) it.next();
u.ContractPerson = req.getParameter("ContractPerson");
u.Company = req.getParameter("Company");
u.Address = req.getParameter("Address");
u.Phone = req.getParameter("Phone");
u.Aid = req.getParameter("Aid");
u.Pin = req.getParameter("Pin");
u.SenderId = req.getParameter("SenderId");
u.Url = req.getParameter("Url");
u.Operater = Integer.parseInt(req.getParameter("Operater"));

pm.makePersistent(u);
}
return;
}

最佳答案

直接使用 PersistenceManager 持久化元素需要关闭持久化管理器,如 the GAE doc clearly states .

关于java - 应用引擎(JAVA): Updating record,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2289179/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com