google-code-export / morphia

Automatically exported from code.google.com/p/morphia
1 stars 0 forks source link

tryVersionedUpdate error when storing one object to different collections #257

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version are you using? (Morphia/Driver/MongoDB)
1.00-snapshot jar r1712

I think the following is an error in DataStorImpl.tryVersionedUpdate:

protected <T> WriteResult tryVersionedUpdate(DBCollection dbColl, T entity, 
DBObject dbObj, WriteConcern wc, DB db, MappedClass mc) {

...

UpdateResults<T> res = update(  find((Class<T>) entity.getClass(), 
Mapper.ID_KEY, idValue).filter(versionKeyName, oldVersion), 
dbObj, 
false, 
false, 
wc);

...

I think 
  find((Class<T>) entity.getClass(), Mapper.ID_KEY, idValue).filter(versionKeyName, oldVersion)

shouldn't try to find based on the entity's class, it should use the passed in 
dbColl.

The reason I noticed this is we are saving a single object to various 
collections dynamically. Relates to:

http://code.google.com/p/morphia/issues/detail?id=248&sort=milestone&colspec=ID%
20Type%20Stars%20Status%20Priority%20Milestone%20Owner%20Summary

If thats not clear, or this doesn't appear correct, please let me know.

Thank you,

Mark

Original issue reported on code.google.com by mwaschko...@gmail.com on 28 Mar 2011 at 2:10

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1732.

Original comment by scotthernandez on 28 Mar 2011 at 6:04

GoogleCodeExporter commented 9 years ago
Ah, OK, cool. Wasn't 100% sure that I was correct with my eval, but glad to 
know that my bug report wasn't off the mark.

Thanks,

Mark

Original comment by mwaschko...@gmail.com on 28 Mar 2011 at 6:26