title: DataNucleus object lookup throws sometimes
body: <p>I am using DataNucleus to persist a ProtoBuf message in MySQL database. When I receive a message I try to store it in my database, however the message might already exist in the database, in this case I update the corresponding row with the new data. Here is the logic I use to detemine whether the message exists in my database:</p>
  
  <pre><code>PersistenceManagerFactory factory = JDOHelper.getPersistenceManagerFactory("Foo");
  PersistenceManager manager = factory.getPersistenceManager();
  Transaction tx = manager.currentTransaction();
  tx.begin();
  MyClass result = manager.getObjectById(MyClass.class, pk /*a string which is the primary key*/);
  if(result == null) //message does not exist
  else //message exists!
  //..more stuff
  tx.commit();
  </code></pre>
  
  <p>The <code>getObjectById</code> method returns null in case of the row does not exist. Based on that I decide whether I want to update the row (if it exists) or add a new row (if it does not exist).
  Suddenly <code>getObjectById</code> started throwing an exception, here is the stack trace:</p>
  
  <pre><code>org.datanucleus.exceptions.NucleusObjectNotFoundException: No such database row
          at org.datanucleus.store.rdbms.request.FetchRequest.execute(FetchRequest.java:359)
          at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.fetchObject(RDBMSPersistenceHandler.java:319)
          at org.datanucleus.state.AbstractStateManager.loadFieldsFromDatastore(AbstractStateManager.java:1147)
          at org.datanucleus.state.StateManagerImpl.validate(StateManagerImpl.java:4294)
          at org.datanucleus.ExecutionContextImpl.findObject(ExecutionContextImpl.java:3553)
          at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1723)
          at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1741)
  </code></pre>
  
  <p>Which is very strange to me since I didn't modify my code. However I started using two instances of my program connected at the same time to MySQL database.</p>
  
  <p>Is it possible that I did something wrong here or is it a concurrency problem with DataNucleus?</p>