Google Appengine - ID 为“com.google.appengine.api.datastore.Key:Product(“Potatoe”)”的对象由不同的对象管理器管理
您好,我遇到了常见错误“由不同的对象管理器管理”,
我在网上浏览过,但没有找到适合我的问题的解决方案。 调用以下代码
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我前段时间遇到了同样的问题,我模糊地记得我的 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.