mongodb - eq expression with objectId generates wrong path #1187

metawave opened this Issue Feb 8, 2015 · 1 comment


None yet
3 participants

metawave commented Feb 8, 2015

If one has an entity person with a manual handled reference (without the morphia @Reference annotation) saving an ObjectId in the object for a reference to an Address entity as shown below.

class Person {
   ObjectId id;

   String name;

   // manual reference to an address
   ObjectId addressId;

the morphia serializer doesn't respect the query:


as shown in the code in the com.mysema.query.mongodb.MongodbSerializer#getKeyForPath:

    protected String getKeyForPath(Path<?> expr, PathMetadata<?> metadata) {
        if (expr.getType().equals(ObjectId.class)) {
            return "_id";
        } else {
            return metadata.getElement().toString();

every path with an objectId type on field automatically gets translated to _id instead of the addressId as shown in the query path expression.

@timowest timowest added the bug label Feb 8, 2015

@timowest timowest added this to the 4.0.0 milestone Feb 8, 2015

This was referenced Feb 8, 2015

@timowest timowest added the progress label Feb 8, 2015

@Shredder121 Shredder121 closed this in #1188 Feb 12, 2015


This comment has been minimized.

Show comment
Hide comment

Shredder121 Feb 12, 2015


Thanks for the report.


Shredder121 commented Feb 12, 2015

Thanks for the report.

@timowest timowest removed the progress label Feb 12, 2015

@timowest timowest removed the progress label Mar 13, 2015

@timowest timowest modified the milestones: 3.6.2, 4.0.0 Mar 31, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment