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
Closed

mongodb - eq expression with objectId generates wrong path #1187

metawave opened this issue Feb 8, 2015 · 1 comment
Labels
bug
Milestone

Comments

@metawave
Copy link

@metawave 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
@timowest timowest added the progress label Feb 8, 2015
@Shredder121
Copy link
Member

@Shredder121 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.