Spring MongoDB @Query parameter ?0 not being substituted -


i using spring/mongodb @query annotation follows @enablemongorepositories specified, string parameter substitution causes parsing/number format exception. when hardcode string date debugging purposes, works. missing dependency or work. here relevant sections:

this works:

@query("{'mydata.fromdatestamp' : { $gte: { $numberlong: \"20130801000000\" } }}") list<mydata> findmydata(); 

this not:

@query("{'mydata.fromdatestamp' : { $gte: { $numberlong: ?0 } }}") list<mydata> findmydata(string fromdatestamp); 

the error:

java.lang.numberformatexception: input string: "_param_0" 

here dependencies:

dependencies {     classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.5.release") } 

...

compile("org.springframework.boot:spring-boot-starter-web") {     exclude module: "spring-boot-starter-tomcat" } compile("org.springframework.boot:spring-boot-starter-jetty") compile("org.springframework.data:spring-data-mongodb") compile("org.mongodb:mongo-java-driver:3.2.2") compile("com.fasterxml.jackson.core:jackson-core:2.8.0") compile("com.fasterxml.jackson.core:jackson-annotations:2.8.0") 

and here config:

@configuration public class mongoconfig extends abstractmongoconfiguration { @override protected string getdatabasename() {     return databasename; }  @bean public mongoclient mongoclient() throws exception {     return new mongoclient(datastorehost,datastoreport); }  @override public mongo mongo() throws exception {     return mongoclient(); }  @bean public mongodbfactory mongodbfactory() throws exception {     return new simplemongodbfactory(mongoclient(), databasename); }  @override @bean public mongotemplate mongotemplate() throws exception {     return new mongotemplate(mongodbfactory()); }  @bean public static propertysourcesplaceholderconfigurer propertyconfigindev() {     return new propertysourcesplaceholderconfigurer(); } 

}

also, have tried these variations fail jsonparseexception:

@query("{'mydata..fromdatestamp' : { $gte: { $numberlong: \"?0\" } }}")  @query("{'mydata..fromdatestamp' : { $gte: { $numberlong: '?0' } }}") 

thanks in advance insight or thoughts!

i changed type long, , worked. had tried changing string long in earlier test, think maybe had $numberlong specified in query json when wasn't needed. although shows numberlong in mongo console date field, worked query. note had added @repository annotation top of interface:

@query(value = "{mydata.fromdatestamp : { $gte: ?0 } }") list<mydata> findmydata(long fromdatestamp); 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -