google-code-export / morphia

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

Accessing @Entity("fs.files") types results in a ClassCastException #308

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am using Morphia trunk from today.
Driver: mongo-2.5.1.jar
Mongod 1.8.2 64bit

Here is the exception:

Exception in thread "main" java.lang.ClassCastException: 
com.mongodb.gridfs.GridFSDBFile cannot be cast to com.mongodb.BasicDBObject
    at com.google.code.morphia.query.MorphiaIterator.getNext(MorphiaIterator.java:60)
    at com.google.code.morphia.query.MorphiaIterator.next(MorphiaIterator.java:47)

The solution is to not use BasicDBObject but the DBObject interface.

I created a patch relative to the directory: 
http://morphia.googlecode.com/svn/trunk/morphia/src/main/java/com/google/code/mo
rphia

See attached.

I grant that my use case is not a common on, but I would argue that using the 
interface is better than the implementation
if one can....

Original issue reported on code.google.com by raymond....@gmail.com on 9 Aug 2011 at 9:03

Attachments:

GoogleCodeExporter commented 9 years ago
I just ran into this myself... the calling contract is for a DBObject, not a 
BasicDBObject. We're anticipating mixing GridFS and Morphia usage.

Original comment by margaret...@gmail.com on 20 Dec 2011 at 4:32