Problem with converting Oracle SQL query to Mongodb Java equivalent

36 views
Skip to first unread message

Russell West

unread,
Sep 20, 2016, 2:44:36 PM9/20/16
to mongodb-user
I am very new to Mongodb development and have been tasked to convert a Java application that originally accessed an Oracle database to access a Mongodb database.  I have been successful in converting simple queries but have not been able to successfully generate the Mongodb Java equivalent to the following Oracle sql query.  Any and all assistance is greatly appreciated.
 
String query_str = "select * from table1 where field1 like " ' + value1 + "%" +  ' " +
                             " and field2 between " + fld2min + " and " fld2max +
                             " and field3 between " + fld3min + " and " fld3max;
 
Thanks,
Russell
                            

Nishant Bhardwaj

unread,
Sep 22, 2016, 11:04:44 PM9/22/16
to mongodb-user

Hi Russell,

As you know MongoDB is a Document database, and usually there is no direct 1-1 mapping between SQL tables and MongoDB collection. Since relational databases and document databases such as MongoDB have different approaches to the same problem. It will be good to review Database Modeling in the MongoDB manual.

You are right in asking how things in SQL world are related to MongoDB terminology. Following links from MongoDB manual are good starting points :

You might as well want to review Use Cases in the MongoDB manual, similar to yours.

Regards,

Nishant

Reply all
Reply to author
Forward
0 new messages