Implementation details of org.axonframework.eventstore.mongo.criteria.MongoProperty.in(Object) method

Hi Allard,

I’m trying to read events from mongo event store with payloadType in list of classes.

I tried to use MongoCriteriaBuilder but it seems the MongoProperty.in(Object) cannot help me create query like the following:

{“payloadType”: {
“$in”: [
“com.my.package.MyEvent”,
“com.my.package.MyOtherEvent”
]
}}

I’m not a Mongo expert, so my assumption is that new BasicDBObject(operator, expression.toString()) () interprets value as a single value adding quotes. So I have the something like the following as the result:
{“payloadType”: {
“$in”: “[
“com.my.package.MyEvent”,
“com.my.package.MyOtherEvent”
]”
}}

Hi Dmitriy,

I’m going to dive into this one. If I remember correctly, the expectations you have of the “in” operator are correct. It’s probably a bug in the implementation.

Thanks for reporting it.

Allard

Hi Dmitriy,

the issue is solved. If you switch to the latest snapshot, it should work properly.

Cheers,

Allard

Hi Allard,

Thank you for quick turnaround.

Regards,
Dmitriy

What code do you use?

If I do:

MongoCriteria criteria = new MongoCriteriaBuilder().property(“payloadType”).in(new String[]{
“com.my.package.MyEvent”,
“com.my.package.MyOtherEvent”});
System.out.println(criteria.asMongoObject().toString());

I get:
{ “payloadType” : { “$in” : [ “com.my.package.MyEvent” , “com.my.package.MyOtherEvent”]}}

Looks like the thing MongoDB will understand.

Allard,

please ignore the “small update.” message. I posted it one minute after the initial message just to include escaped quotes, but email seems to be delivered after you’ve updated the code.

Regards,
Dmitriy