0
嗨,我碰到了「由不同對象管理器管理的常見錯誤「Google Appengine - id爲「com.google.appengine.api.datastore.Key:Product(」Potatoe「)」的對象由不同的對象管理器管理
我在網上看了一圈,沒有找到適合我的問題的解決方案。我在JSP頁面中調用以下代碼
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();
}
}
被扔在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)
也許是一個複製... http://stackoverflow.com/questions/1403515/appengine-datastore-object-with-id-is-managed-by-a-different-object-manager – 2011-04-06 13:55:38