in Education by
Following query is perfectly working in mongo shell. db.collection.find({ "_id" : UUID("87aa9ed6-8485-4517-8e90-08e521372e9a")}) I want to achieve same programmatically in java. I have tried below approaches but not getting any result. 1) collection.find(eq("_id", "87aa9ed6-8485-4517-8e90-08e521372e9a")); 2) `UUID uuid = UUID.fromString("87aa9ed6-8485-4517-8e90-08e521372e9a"); collection.find(eq("_id", uuid));` JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You can use this for single UUID if you have a mongoTemplate defined Query query= new Query(); query.addCriteria(Criteria.where("_id").is(uuid)); mongoTemplate.findOne(query,YourObjectName.class); If you have multiple UUIDs you can use criteria orOperator Query query= new Query(); Criteria criteria=new Criteria(); List orCriteria=new ArrayList<>(); String[] splitId=ids.split(","); for(String id:splitId){ UUID uuid = UUID.fromString(id); orCriteria.add(Criteria.where("_id").is(uuid)); } criteria.orOperator(orCriteria.toArray(new Criteria[orCriteria.size()])); query.addCriteria(criteria); mongoTemplate.find(query,YourObjectName.class); Lmk if that works.

Related questions

0 votes
    I have two collection vmdetails and rsc_installtion_status , i want to select the documents from rsc_installtion_status ... Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    Input: {_id:ObjectID(123),ip:'123.123.123.123'} {_id:ObjectID(123),ip:'123.123.123.123'} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have a requirement to return the same length of the array provided to mongo. usernames = ['user1' ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Input: {_id:ObjectID(123),ip:'123.123.123.123'} {_id:ObjectID(123),ip:'123.123.123.123'} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    Input: {_id:ObjectID(123),ip:'123.123.123.123'} {_id:ObjectID(123),ip:'123.123.123.123'} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I tried mongo replica sets for the first time. I am using ubuntu on ec2 and I booted up three instances ... replicate across machines? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I want to query something with SQL's like query: SELECT * FROM users WHERE name LIKE '%m%' How to do I ... like in the documentation. Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    Java in computer programming is a- (a) Compiler (b) Hardware Device Driver (c) Low-level Language (d ... Programming Mid-level Language Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    write a menu driver program in java for the following pattern ** *** * * * * * * Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    I inserted in PostgreSQL table an UUID created with go.uuid : import ( "github.com/satori/go.uuid" ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I inserted in PostgreSQL table an UUID created with go.uuid : import ( "github.com/satori/go.uuid" ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I got this query: User.collection.aggregate([ {"$project" => { "dayOfMonth" => {"$dayOfMonth" => ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    Mongo client will generate _____ command to initiate a new replica set. (1)rs.initiate() (2)rs.conf() (3)db.isMaster() (4)rs.status()...
asked May 22, 2021 in Technology by JackTerrance
+1 vote
    Mongo client will generate _____ command to initiate a new replica set. (1)rs.initiate() (2)rs.conf() (3)db.isMaster() (4)rs.status()...
asked Oct 13, 2020 in Technology by JackTerrance
0 votes
    Is there a Java package providing funcionality like the .Net System.Data namespace ? Specificaly the DataSet ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
...