Hi Team, When i add sort function to the existing query for MongoDB using hibernate ogm im getting java.lang.IllegalArgumentException, yet the same query is running fine in the mongo shell...Iam using hibernateOGM 5.0.0.CR1...

at org.hibernate.ogm.datastore.mongodb.MongoDBDialect.parseNativeQuery(MongoDBDialect.java:863) at org.hibernate.ogm.datastore.mongodb.MongoDBDialect.parseNativeQuery(MongoDBDialect.java:143) at org.hibernate.ogm.dialect.impl.ForwardingGridDialect.parseNativeQuery(ForwardingGridDialect.java:200) at org.hibernate.ogm.query.impl.NativeNoSqlQueryInterpreter.getCustomQuery(NativeNoSqlQueryInterpreter.java:50) at org.hibernate.ogm.query.impl.NativeNoSqlQueryInterpreter.createQueryPlan(NativeNoSqlQueryInterpreter.java:45) at org.hibernate.engine.query.spi.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:210) at org.hibernate.ogm.hibernatecore.impl.OgmSessionImpl.list(OgmSessionImpl.java:301) at org.hibernate.ogm.query.impl.NoSQLQueryImpl.list(NoSQLQueryImpl.java:130) at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:593) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:470)

I've tried to propose this issue to some contributors but nobody started working on it yet.One of us might decide to tackle this issue but if you want to speed up the processyou can try to vote for it on the JIRA or propose a solution yourself, that would be much appreciated.

Any ideas on how to do an order by/sort? $orderby was deprecated in MongoDB in v3.2, and .sort() is not supported in Hibernate OGM 5.0.2.

Also, it's not quite clear to me why native queries don't just simply "work". I resorted to using a native query because of a limitation of JPA support (I think it was OGM-825). If any one can provide some literature on this I would appreciate it.

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]