Java Entity Manager - JSON reader was expecting a value but found 'db' -


i have code working:

entitymanager entitymanager = getentitymanager(); entitymanager.gettransaction().begin(); string query = "db.band.find({})"; list<band> list = (list<band>) entitymanager.createnativequery(query, band.class).getresultlist(); entitymanager.close(); return list; 

it returns list no problem. want sort list date:

entitymanager entitymanager = getentitymanager(); entitymanager.gettransaction().begin(); string query = "db.band.find({something__id:objectid(\"" + myid + "\")}).sort({\"somethingelse.date\":-1})"; list<band> list = (list<band>) entitymanager.createnativequery(query, band.class).getresultlist(); entitymanager.close(); return list; 

my console gives me message:

org.bson.json.jsonparseexception: json reader expecting value found 'db' 

i checked string working in mongo console , did. ideas?

edit: tried putting "something__id" between quotes because wouldn't work without sort part if didn't (i realised that), says making unsupported native query, pointing out sort part. should sort after have in list object?

this answer late, battling same issue ages perhaps it'll else.

as per this forum post, keys , values must both enclosed in quotation marks, something__id should "something__id".


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -