mongodb - Spring MongoRepository query adding _class field to queries -
i have domain class called user. uses object of myuserid
id
@document(collection = "users") public class user implements serializable { @property @id private myuserid id; @version private integer version; private string firstname; // setters, getters }
the myuserid
class:
public class myuserid implements serializable{ @property private string userid; @property private string sampleid; // setters, getters }
inside mongo, documents getting stored {_id:{userid:....., sampleid:....}, <more fields here>}
my userrepository this:
public interface userrepository extends mongorepository<user, myuserid> { @query("{'_id': {$in: ?0}}") list<user> findbyuserids(collection<myuserid> userids); }
when i'm querying userrepository, query beingness fired as:
{_id: {$in: [ {_class:"com.sampleuser.myuserid", userid:"....", sampleid:"...."}, {_class:"com.sampleuser.myuserid", userid:"....", sampleid:"...."}]}}
it's obvious it's adding _class field while querying, not while storing. can throw lite @ how prepare this? it's causing queries fail. give thanks you!
there exists issue when using @query
whith complex id types. i'd suggest utilize custom repository implementation until datamongo-1078 resolved.
within custom implementation utilize mongotemplate
execute query somehow this
@override public list<user> findbyuserids(collection<myuserid> userids) { homecoming template.find(query(where("id").in(userids)), user.class); }
spring mongodb spring-data spring-data-mongodb
No comments:
Post a Comment