[ 
https://issues.apache.org/jira/browse/METAMODEL-211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15026705#comment-15026705
 ] 

Mykhailo Kozik commented on METAMODEL-211:
------------------------------------------

Could we apply such workaround in 
MongoDBDataContext.executePrimaryKeyLookupQuery?

// if id is autogenerated hex string by mongodb wrap it into ObjectId
if (ColumnType.ROWID == selectItem.getColumn().getType() &&
    ObjectId.isValid(keyValue.toString())) {
    keyValue = new ObjectId(keyValue.toString());
}

> Primary key query in MongoDB does not find the record
> -----------------------------------------------------
>
>                 Key: METAMODEL-211
>                 URL: https://issues.apache.org/jira/browse/METAMODEL-211
>             Project: Apache MetaModel
>          Issue Type: Bug
>    Affects Versions: 4.4.1
>            Reporter: Tomasz Guzialek
>
> Primary key query in MongoDbDataContext does not return the record despite it 
> being there. Example query:
> {code:java}
> DataSet ds = dc.query()
>             .from("users")
>             .selectAll()
>             .where("_id").eq("56334c6fb38cfec169db2ccb")
>             .execute();
> {code}
> My suspition is that in the query we have the _id in a form of a String while 
> the _id field in Mongo is actually a new ObjectId("56334c6fb38cfec169db2ccb") 
> and therefore it does not match.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to