AppEngine datastore: “Object with id … is managed by a different Object Manager”

后端 未结 3 1501
灰色年华
灰色年华 2020-12-10 13:50

I\'m using the Google AppEngine, with Java. When I use some datastore features, I\'m getting an error message:

Object with id \"edvaltt.Teacher@64064b\" i         


        
相关标签:
3条回答
  • 2020-12-10 14:00

    As illustrated in this ticket, shouldn't you close the pm (PersistenceManager)?

    } finally {
        tx.commit();
        pm.close();
    }
    
    0 讨论(0)
  • 2020-12-10 14:17

    DataNucleus,

    Thank you for the pm.close(); tip. I was making a query with one em

    em = EMF.get().createEntityManager();

    and making a commit with another one without closing the first one.

    0 讨论(0)
  • 2020-12-10 14:19

    A persistent object can only be "managed" by one PersistenceManager. In DataNucleus this is backed internally by an "ObjectManager". The message says that you are trying to associate an object managed by one PM with a different PM. You can easily debug that by printing out the PM for each (persistent) object

    JDOHelper.getPersistenceManager(obj);
    

    Since you don't define where the message comes from, not much more can be said. The DataNucleus log entries would tell you way way more than that.

    Closing the PM is always an essential thing to do (unless you want resource leaks)

    0 讨论(0)
提交回复
热议问题