mongodb - Spring Data Mongo DB Repository FindBy not working -
i'm trying add custom query mongorepository instance, it's not working. section 10.3 in here describes i'm trying do. i've tried 4 different ways of doing it, nothing seems work...
my code
public interface myrepository extends mongorepository<studenteo,customid>{      //1st attempt.      //studenteo findbyfirstname(string firstname);      //2nd attempt.      //@query("{ 'firstname' : ?0 }")     //studenteo findbyfirstname(string firstname);      //3rd attempt.     //list<studenteo> findbyfirstname(string firstname);      //4th attempt     @query("{ 'firstname' : ?0 }")     list<studenteo> findbyfirstname(string firstname); }  @document(collection = "data_point_metadata") public class studenteo {      @id     private customid id;     private string firstname;     private string lastname;     private studenttype studenttype;      ...      getters , setters... }  @component public class stringtostudenttypeconverter implements converter<string, studenttype> {      @override      public studenttype convert(string source) {          if(source == null){             return null;         }          try{             return studenttype.valueof(source.trim().touppercase());         }catch(exception e){             logger.error("invalid datatype value - "+e.getmessage());         }         return null;     } } in logs see:
c.f.f.s.w.m.u.stringtodatatypeconverter - invalid studenttype value - no enum constant ...studenttype.john o.s.data.mongodb.core.mongotemplate - find using query: { "firstname" :  null } fields: null ...  and don't back. when debug it, service layers passing valid firstname. not null.
i'm using default findall() repository method, , works fine.
pagerequest pagerequest = new pagerequest(pagenumber, pagesize != 0 ? pagesize : defaultpagesize); page<studenteo> studentspage = myrepository.findall(pagerequest); what doing wrong?
i'm using following version of spring apis:
- spring-core 4.1.7.release
- spring-data-commons 1.9.3.release
- spring-data-mongodb 1.6.3.release
 
 
  
Comments
Post a Comment