Also apply on appspot. On Jul 7, 10:22 am, John Patterson <jdpatter...@gmail.com> wrote: > Local dev server does not implement transactions > > On 7 Jul 2010, at 09:21, Tapir wrote: > > > > > Please see the following code, the IllegalArgumentException should be > > throwed but not. > > > // before calling this function, all File entities > > // have already been created. > > public void ImportData (DataInputStream dis) throws Exception { > > > // this is bug! This line should be put in the for loop. > > // see below. > > List entityList = new ArrayList (); > > > PersistenceManager pm = pmf.get().getPersistenceManager(); > > > int numFiles = dis.readShort (); // about 20 > > for (int i = 0; i < numFiles; ++ i) { > > Transaction tx = pm.currentTransaction(); > > try { > > tx.begin(); > > > // the beginning line should be here > > //List entityList = new ArrayList (); > > > String filename = dis.readUTF (); > > // ... more fields > > > Key fileKey = KeyFactory.createKey > > (FileInfo.class.getSimpleName(), > > filename); > > FileInfo fileInfo = > > pm.getObjectById(FileInfo.class, fileKey); > > fileInfo.setFilename(filename); > > // ... more fields > > > entityList.add (fileInfo); > > > int numRevisions = dis.readInt (); // about 5 > > for (int j = 0; j < numRevisions; ++ j) { > > int revisionId = dis.readShort (); > > // ... more fields > > > Key revisionKey = KeyFactory.createKey > > (fileKey, > > > > FileRevision.class.getSimpleName(), revisionId); > > FileRevision fileRevision = new > > FileRevision(); > > fileRevision.setId(revisionKey); > > fileRevision.setRevisionId(revisionId); > > // ... more fields > > > entityList.add (fileRevision); > > } > > > // because the bug mentioned above, > > entityList.size () > > // will increase to about 100 in the end. > > // The strange thing is the following calling > > will never > > // throw Exceptions, although apparently > > // there are many entity groups in the > > entityList. > > > pm.makePersistentAll (entityList); > > > // using makePersistent instead of > > makePersistentAll > > // will also never throw Exceptions. > > > //for (Object entity : entityList) { > > // pm.makePersistent (entity); > > //} > > > tx.commit (); > > } catch (Exception e) { > > e.printStackTrace(); > > > if (tx.isActive()) { > > tx.rollback(); > > } > > > throw e; > > } fanally { > > pm.close (); > > } > > } > > } > > > -- > > You received this message because you are subscribed to the Google > > Groups "Google App Engine for Java" group. > > To post to this group, send email to google-appengine-java@googlegroups.com > > . > > To unsubscribe from this group, send email to > > google-appengine-java+unsubscr...@googlegroups.com > > . > > For more options, visit this group > > athttp://groups.google.com/group/google-appengine-java?hl=en > > .- Hide quoted text - > > - Show quoted text -
-- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.