hi
currently the bug which was reported seem to be resolved in 5.x version.
https://hibernate.atlassian.net/browse/OGM-1024I was trying to perform an aggregate function for a native query.
db.user_interaction.aggregate([ {'$unwind':'$page_session'}, {'$unwind': '$page_session.click'}, {'$match' : {'page_session.click.resource_name':'campaign'}}, {'$group':{ '_id':'$page_session.click.resource_id', 'averageSessionDuration': {'$avg':'$page_session.timespent'}, 'viewerCount':{'$sum':1} }}])
I get the error
I am not sure if i am missing something here.
Caused by: org.bson.json.JsonParseException: JSON reader was expecting a value but found 'db'.
at org.bson.json.JsonReader.readBsonType(JsonReader.java:237) ~[mongo-java-driver-3.4.2.jar:?]
at com.mongodb.DBObjectCodec.readDocument(DBObjectCodec.java:345) ~[mongo-java-driver-3.4.2.jar:?]
at com.mongodb.DBObjectCodec.decode(DBObjectCodec.java:138) ~[mongo-java-driver-3.4.2.jar:?]
at com.mongodb.DBObjectCodec.decode(DBObjectCodec.java:61) ~[mongo-java-driver-3.4.2.jar:?]
at com.mongodb.BasicDBObject.parse(BasicDBObject.java:75) ~[mongo-java-driver-3.4.2.jar:?]
at com.mongodb.BasicDBObject.parse(BasicDBObject.java:62) ~[mongo-java-driver-3.4.2.jar:?]
at org.hibernate.ogm.datastore.mongodb.query.parsing.nativequery.impl.MongoDBQueryDescriptorBuilder.parse(MongoDBQueryDescriptorBuilder.java:99) ~[hibernate-ogm-mongodb-5.0.4.Final.jar:5.0.4.Final]
at org.hibernate.ogm.datastore.mongodb.query.parsing.nativequery.impl.MongoDBQueryDescriptorBuilder.build(MongoDBQueryDescriptorBuilder.java:78) ~[hibernate-ogm-mongodb-5.0.4.Final.jar:5.0.4.Final]
at org.hibernate.ogm.datastore.mongodb.MongoDBDialect.parseNativeQuery(MongoDBDialect.java:862) ~[hibernate-ogm-mongodb-5.0.4.Final.jar:5.0.4.Final]
at org.hibernate.ogm.datastore.mongodb.MongoDBDialect.parseNativeQuery(MongoDBDialect.java:143) ~[hibernate-ogm-mongodb-5.0.4.Final.jar:5.0.4.Final]
at org.hibernate.ogm.dialect.impl.ForwardingGridDialect.parseNativeQuery(ForwardingGridDialect.java:200) ~[hibernate-ogm-core-5.0.4.Final.jar:5.0.4.Final]
at org.hibernate.ogm.query.impl.NativeNoSqlQueryInterpreter.getCustomQuery(NativeNoSqlQueryInterpreter.java:50) ~[hibernate-ogm-core-5.0.4.Final.jar:5.0.4.Final]
at org.hibernate.ogm.query.impl.NativeNoSqlQueryInterpreter.createQueryPlan(NativeNoSqlQueryInterpreter.java:45) ~[hibernate-ogm-core-5.0.4.Final.jar:5.0.4.Final]
at org.hibernate.engine.query.spi.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:210) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.ogm.hibernatecore.impl.OgmSessionImpl.list(OgmSessionImpl.java:301) ~[hibernate-ogm-core-5.0.4.Final.jar:5.0.4.Final]
at org.hibernate.ogm.query.impl.NoSQLQueryImpl.list(NoSQLQueryImpl.java:130) ~[hibernate-ogm-core-5.0.4.Final.jar:5.0.4.Final]
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:606) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:483) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]