Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongodb - eq expression with objectId generates wrong path #1187

Closed
metawave opened this issue Feb 8, 2015 · 1 comment · Fixed by #1188
Closed

mongodb - eq expression with objectId generates wrong path #1187

metawave opened this issue Feb 8, 2015 · 1 comment · Fixed by #1188
Labels
Milestone

Comments

@metawave
Copy link

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 {
   @Id
   ObjectId id;

   String name;

   // manual reference to an address
   ObjectId addressId;
}

the morphia serializer doesn't respect the query:

QPerson.person.addressId.eq(<objectId>)

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
@Shredder121
Copy link
Member

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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants