You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is Issue 191 moved from a Google Code project.
Added by 2010-12-22T02:04:03.000Z by mrbur...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.
Closed (Fixed).
Original labels: Type-Defect, Priority-Low
Original description
Problem code
Query<UserGroup> query = createQuery()
.field("_id").equal(group.getId());
query.and(query.criteria("user").doesNotExist());
UpdateOperations<UserGroup> ops = getDatastore()
.createUpdateOperations(UserGroup.class)
.set("user", user);
update(query, ops);
Solution (Per skot)
Query<UserGroup> query = createQuery()
.field("_id").equal(group.getId());
query.and(query.criteria("user").doesNotExist());
UpdateOperations<UserGroup> ops = getDatastore()
.createUpdateOperations(UserGroup.class)
.set("user", getDatastore().getKey(user));
update(query, ops);
The user in UserGroup is decorated with @Reference. Instead of the object being set as a DBRef, it used a BasicDBObject which resulted in the exception below.
<b>What version are you using? (Morphia/Driver/MongoDB)</b>
0.99-SNAPSHOT
<b>Please include a stack trace below:</b>
java.lang.RuntimeException: java.lang.ClassCastException: com.mongodb.BasicDBObject cannot be cast to com.mongodb.DBRef
at com.google.code.morphia.mapping.Mapper.fromDb(Mapper.java:421)
at com.google.code.morphia.mapping.Mapper.fromDBObject(Mapper.java:265)
at com.google.code.morphia.query.MorphiaIterator.processItem(MorphiaIterator.java:53)
at com.google.code.morphia.query.MorphiaIterator.next(MorphiaIterator.java:48)
at com.google.code.morphia.query.QueryImpl.get(QueryImpl.java:340)
at com.google.code.morphia.DatastoreImpl.get(DatastoreImpl.java:498)
at com.google.code.morphia.dao.BasicDAO.get(BasicDAO.java:163)
The text was updated successfully, but these errors were encountered:
This is Issue 191 moved from a Google Code project.
Added by 2010-12-22T02:04:03.000Z by mrbur...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.
Closed (Fixed).
Original labels: Type-Defect, Priority-Low
Original description
The text was updated successfully, but these errors were encountered: