Google Appengine - ID 为“com.google.appengine.api.datastore.Key:Product(“Potatoe”)”的对象由不同的对象管理器管理

发布于 2024-08-18 06:38:19 字数 1837 浏览 3 评论 0原文

您好,我遇到了常见错误“由不同的对象管理器管理”,

我在网上浏览过,但没有找到适合我的问题的解决方案。 调用以下代码

PersistenceManager pm = PMF.get().getPersistenceManager();
String query = "SELECT FROM " +Location.class.getName();
List<Location> locTs = (List<Location>) pm.newQuery(query).execute();
for (Location location : locTs) {
   location.genRes(pm);
}
pm.close();
return "done";

我从 JSP 页面location.genRes

 public void genRes(PersistenceManager pm) {
 Key product = this.getLtype(pm).getProductKey();
 String query = "SELECT FROM " + LocationInventry.class.getName() + " WHERE location == '"+key.getId()+"' && product == '"+product.getId()+"'";
 List<LocationInventry> lvd = (List<LocationInventry>) pm.newQuery(query).execute(); 
 if (lvd.size() == 0 ) {
  LocationInventry locationInventry = new LocationInventry(product, this);
  pm.makePersistent(locationInventry);
 } 
 else {
  lvd.get(0).gen();
 }
}

pm.makePersistent(locationInventry); 引发错误

据我所知,我只使用一种持久管理,并且在使用后将其关闭。感谢您的任何帮助。

Object with id "com.google.appengine.api.datastore.Key:Product("Potatoe")" is managed by a different Object Manager
org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:375)
org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:674)
org.datanucleus.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:694)
net.sparktank.quilage.datastore.Location.genRes(Location.java:220)
net.sparktank.quilage.server.MainRunner.genResources(MainRunner.java:239)
org.apache.jsp.server.generateResources_jsp._jspService(generateResources_jsp.java:45)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:806)

Hi i am hitting the common error "managed by a different object manager"

I have looked around online and not found a solution that fits my problem. I am calling the following code from a JSP page

PersistenceManager pm = PMF.get().getPersistenceManager();
String query = "SELECT FROM " +Location.class.getName();
List<Location> locTs = (List<Location>) pm.newQuery(query).execute();
for (Location location : locTs) {
   location.genRes(pm);
}
pm.close();
return "done";

location.genRes

 public void genRes(PersistenceManager pm) {
 Key product = this.getLtype(pm).getProductKey();
 String query = "SELECT FROM " + LocationInventry.class.getName() + " WHERE location == '"+key.getId()+"' && product == '"+product.getId()+"'";
 List<LocationInventry> lvd = (List<LocationInventry>) pm.newQuery(query).execute(); 
 if (lvd.size() == 0 ) {
  LocationInventry locationInventry = new LocationInventry(product, this);
  pm.makePersistent(locationInventry);
 } 
 else {
  lvd.get(0).gen();
 }
}

The error is being thrown on pm.makePersistent(locationInventry);

As far as I can tell I am using only one persistent management and I am closing it after use. Thanks for any help.

Object with id "com.google.appengine.api.datastore.Key:Product("Potatoe")" is managed by a different Object Manager
org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:375)
org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:674)
org.datanucleus.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:694)
net.sparktank.quilage.datastore.Location.genRes(Location.java:220)
net.sparktank.quilage.server.MainRunner.genResources(MainRunner.java:239)
org.apache.jsp.server.generateResources_jsp._jspService(generateResources_jsp.java:45)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:806)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

罪#恶を代价 2024-08-25 06:38:19

我前段时间遇到了同样的问题,我模糊地记得我的 jdoconfig.xml 文件丢失或配置不正确。
请查看 http://code.google.com/appengine/docs/ java/datastore/usingjdo.html 了解更多详细信息。

I had this same problem some time ago and I have a vague memory that my jdoconfig.xml file was missing or not configured correctly.
Check out http://code.google.com/appengine/docs/java/datastore/usingjdo.html for more details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文