{"id":80792,"date":"2018-08-21T07:00:34","date_gmt":"2018-08-21T04:00:34","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=80792"},"modified":"2018-08-20T15:53:55","modified_gmt":"2018-08-20T12:53:55","slug":"mongodb-tutorial-for-beginners","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html","title":{"rendered":"MongoDB Tutorial for Beginners"},"content":{"rendered":"<h2>1. Introduction to MongoDB<\/h2>\n<p>In this post, we feature a comprehensive MongoDB Tutorial that integrates with a Java-based application. Whenever we read about NoSQL databases, we need to know why were they ever developed when SQL databases were working excellent. NoSQL foundations grew upon relaxed <strong>ACID<\/strong> (atomicity, consistency, isolation, durability) guarantees in favour of performance, scalability, flexibility and reduced complexity. Most NoSQL databases have gone one way or another in providing as many of the previously mentioned qualities as possible, even offering tunable guarantees to the developer.<\/p>\n<p>MongoDB is an open-source, document-oriented, and cross-platform database which is developed in C++ and is one of the most popular and used NoSQL type databases. It works on top of JSON-like documents with key-value pairs whose schema can remain undefined across every document. Also, it is free to use as it is published under a combination of the GNU <a href=\"https:\/\/en.wikipedia.org\/wiki\/Affero_General_Public_License\" target=\"_blank\" rel=\"noopener\">Affero General Public License<\/a> and the Apache License. MongoDB stores data in JSON-like documents (called BSON), which can have a dynamic schema across documents in the same collections. The structure of a document in the same collection can be changed by simply adding new fields or deleting existing ones.<\/p>\n<p>In this post we will study some of the characteristics of this NoSQL Database and how it evolved across various versions, adding new features with improved scalability and performance. We will also develop a small <a href=\"https:\/\/examples.javacodegeeks.com\/enterprise-java\/maven\/maven-tutorial-for-beginners\/\" target=\"_blank\" rel=\"noopener\">Maven<\/a>-based Java project in which we will run some of the sample queries with MongoDB driver for <a href=\"https:\/\/www.javacodegeeks.com\/category\/java\" target=\"_blank\" rel=\"noopener\">Java<\/a>.<\/p>\n<h2>2. MongoDB evolution<\/h2>\n<p>MongoDB was developed by 10gen and it was first released on August 27th, 2009. The first version for MongoDB was released with some basic features, authorization, and ACID guarantees which made up for shortcomings with performance and flexibility. Again, some basic features for v1.0 and v1.2 were:<\/p>\n<ul>\n<li>JSON-based document model<\/li>\n<li>Global lock at process level<\/li>\n<li>Indexes on collections which resides on RAM (majorly)<\/li>\n<li>CRUD operations on documents in a collection<\/li>\n<li>Replication support in a Master Slave architecture<\/li>\n<li>Map-Reduce (supported in v1.2)<\/li>\n<li>Javascript functions (supported in v1.2)<\/li>\n<\/ul>\n<p>Soon after the initial versions, next version of MongoDB brought many new features and exciting improvements on indexed collections and built upon previous feature set as well. To list down the evolution, here are some features which were present in Version 2 of MongoDB release:<\/p>\n<ul>\n<li>Sharding (supported in v1.6)<\/li>\n<li>Query operators (supported in v1.6)<\/li>\n<li>Sparse and covered indexes (supported in v1.8)<\/li>\n<li>Much more efficient memory usage<\/li>\n<li>Concurrency improvements<\/li>\n<li>MapReduce improvements<\/li>\n<li>Authentication (supported in v2.0 for Sharding)<\/li>\n<li>Geospatial query and data support<\/li>\n<\/ul>\n<p>Now, with the advent of much more data in the databases of most of the organisations, there was a need of much more performance increase, faster indexes and searchable documents. All of these demands were correctly answered in the Version 3 of MongoDB. Here are the features which were a major boost which made MongoDB one of the most used NoSQL Database:<\/p>\n<ul>\n<li>Aggregation Framework (supported in v2.2)<\/li>\n<li>Text search (supported in v2.4)<\/li>\n<li>Hashed indexes (supported in v2.4)<\/li>\n<li>Security enhancements, role-based access to databases (supported in v2.4)<\/li>\n<li>V8 JavaScript engine (replacing SpiderMonkey, since v2.4)<\/li>\n<li>Query engine improvements (since v2.6)<\/li>\n<li>Document validation (since v3.2)<\/li>\n<li>Multiple storage engines (since v3.2, Enterprise edition only)<\/li>\n<\/ul>\n<p>When we start to notice the features MongoDB has been adding since it started to evolve, we can easily see that at its current state, MongoDB is a database that can handle loads of data ranging from startup MVPs and POCs to enterprise applications with hundreds of servers and more.<\/p>\n<h2>3. MongoDB Terminologies for SQL Developers<\/h2>\n<p>We can understand MongoDB concepts much faster if we establish a comparison between SQL terminologies and NoSQL concepts. Here is a simple analogy comparison between Mongo and a traditional MySQL system:<\/p>\n<ul>\n<li>Tables in MySQL becomes Collections in MongoDB<\/li>\n<li>A row beomes a document<\/li>\n<li>Column becomes a field<\/li>\n<li>Joins are defined as linking and embedded documents (more on this later)<\/li>\n<\/ul>\n<p>To clear any misconceptions, this was just a simple way to look at MongoDB concepts and each of them might not be strictly applied on their MongoDB counterparts but it was nevertheless important.<\/p>\n<h2>4. Making the Java Project with Maven<\/h2>\n<p>We will be using one of the many Maven archetypes to create a sample project for our example. To create the project execute the following command in a directory that you will use as workspace:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Creating a Project<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mvn archetype:generate -DgroupId=com.javacodegeeks.example -DartifactId=JCG-JavaMongoDB-Example -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false\r\n<\/pre>\n<p>If you are running maven for the first time, it will take a few seconds to accomplish the generate command because maven has to download all the required plugins and artifacts in order to make the generation task. Once we run this project, we will see the following output and the project will be created:<\/p>\n<p><figure id=\"attachment_80796\" aria-describedby=\"caption-attachment-80796\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/project-setup.png\"><img decoding=\"async\" class=\"wp-image-80796 size-full\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/project-setup.png\" alt=\"MongoDB Tutorial - Project setup\" width=\"820\" height=\"567\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/project-setup.png 820w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/project-setup-300x207.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/project-setup-768x531.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-80796\" class=\"wp-caption-text\">Java MongoDB Project setup<\/figcaption><\/figure><\/p>\n<h2>5. Adding Maven dependencies<\/h2>\n<p>Once you have created the project, feel free to open it in your favourite IDE. Next step is to add appropriate Maven Dependencies to the project. We will work with the following dependencies in our project:<\/p>\n<ul>\n<li><code>mongo-java-driver<\/code>: This dependency brings the MongoDB driver for Java into our dependencies.<\/li>\n<\/ul>\n<p>Here is the <code>pom.xml<\/code> file with the appropriate dependencies added:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n         xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/maven-v4_0_0.xsd\"&gt;\r\n    &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\r\n\r\n    &lt;groupId&gt;com.javacodegeeks.example&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;JCG-JavaMongoDB-Example&lt;\/artifactId&gt;\r\n    &lt;packaging&gt;jar&lt;\/packaging&gt;\r\n    &lt;version&gt;1.0-SNAPSHOT&lt;\/version&gt;\r\n    &lt;name&gt;JCG-JavaMongoDB-Example&lt;\/name&gt;\r\n    &lt;url&gt;http:\/\/maven.apache.org&lt;\/url&gt;\r\n\r\n    &lt;dependencies&gt;\r\n\r\n        &lt;dependency&gt;\r\n            &lt;groupId&gt;org.mongodb&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;mongo-java-driver&lt;\/artifactId&gt;\r\n            &lt;version&gt;3.4.1&lt;\/version&gt;\r\n        &lt;\/dependency&gt;\r\n\r\n    &lt;\/dependencies&gt;\r\n\r\n&lt;\/project&gt;\r\n<\/pre>\n<p>If you want to check and use a newer version for the driver, check the releases <a href=\"https:\/\/search.maven.org\/#search%7Cgav%7C1%7Cg:%22org.mongodb%22%20AND%20a:%22mongo-java-driver%22\" target=\"_blank\" rel=\"noopener\">here<\/a>.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Finally, to understand all the JARs which are added to the project when we added this dependency, we can run a simple Maven command which allows us to see a complete Dependency Tree for a project when we add some dependencies to it. This dependency tree will also show how many dependencies were added when we added some of our own dependencies in a well-placed hierarchial manner. Here is a command which we can use for the same:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Check Dependency Tree<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mvn dependency:tree\r\n<\/pre>\n<p>When we run this command, it will show us the following Dependency Tree:<\/p>\n<p><figure id=\"attachment_80800\" aria-describedby=\"caption-attachment-80800\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/dependency-tree.png\"><img decoding=\"async\" class=\"wp-image-80800 size-full\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/dependency-tree.png\" alt=\"MongoDB Tutorial - Check Dependency Tree\" width=\"820\" height=\"322\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/dependency-tree.png 820w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/dependency-tree-300x118.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/dependency-tree-768x302.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-80800\" class=\"wp-caption-text\">Check Dependency Tree<\/figcaption><\/figure><\/p>\n<p>Clearly, this is a quite simple project as it has just one Maven dependency added into it.<\/p>\n<h2>6. Project Structure<\/h2>\n<p>Before we move on and start working on the code for the project, let\u2019s present here the project structure we will have once we\u2019re finished adding all the code to the project so that we know where to places classes we will make in this project:<\/p>\n<p><figure id=\"attachment_80807\" aria-describedby=\"caption-attachment-80807\" style=\"width: 488px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/project-structure.png\"><img decoding=\"async\" class=\"wp-image-80807 size-full\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/project-structure.png\" alt=\"MongoDB Tutorial - Project Structure\" width=\"488\" height=\"312\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/project-structure.png 488w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/project-structure-300x192.png 300w\" sizes=\"(max-width: 488px) 100vw, 488px\" \/><\/a><figcaption id=\"caption-attachment-80807\" class=\"wp-caption-text\">Project Structure<\/figcaption><\/figure><\/p>\n<p>We have used a single class in this application as it fulfilled all of our purposes. We can break this class into multiple classes based on operations we need to do and when our project expands to more complex operations.<\/p>\n<h2>7. Using MongoDB with Java<\/h2>\n<p>Now, we can start using MongoDB queries in the Java project we just made. We will start with basic CRUD operations followed by pagination implementation and much more queries. Before proceeding to the code examples, please make sure to <a href=\"https:\/\/www.javacodegeeks.com\/2015\/09\/mongodb-installation-how-to-install-mongodb.html\" target=\"_blank\" rel=\"noopener\">install and run MongoDB on your machine<\/a>.<\/p>\n<h3>7.1 Making a connection with MongoDB<\/h3>\n<p>The first step to work with a database in any application is to connect to it. We can connect to MongoDB by authenticating against the <code>authentication-database<\/code> (<code>admin<\/code> by default) in following manner:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>MongoApp.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">System.out.println(\"Connecting to DB...\");\r\nList&lt;MongoCredential&gt; credentialsList = new ArrayList&lt;&gt;();\r\n\/\/Use username, authtication database and password in MongoCredential object\r\nMongoCredential creds = MongoCredential.createCredential(\"db_user\", \"admin\", \"db_password\".toCharArray());\r\ncredentialsList.add(creds);\r\nServerAddress serverAddress = new ServerAddress(\"localhost\", 27017); \/\/host and port\r\nMongoClient mongoClient = new MongoClient(serverAddress, credentialsList);\r\nSystem.out.println(\"Connected to MongoDB...\");\r\n<\/pre>\n<p>The above code can be used when we are connecting to an authenticated database which is secured and has authentication enabled. If you haven&#8217;t secured your MongoDB installation yet, you can simply use:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>MongoApp.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">MongoClient mongoClient = new MongoClient(\"localhost\", 27017);\r\n<\/pre>\n<p>We are now ready to run various commands with this <code>MongoClient<\/code> object which has established and stored a DB connection in it.<\/p>\n<h3>7.2 Show Existing Databases<\/h3>\n<p>We will start by displaying all databases which exist in our system which current user can access (if the installation is secured with authentication). To do this in Mongo shell, we can run the following simple command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Show Databases with Mongo shell<\/em><\/span><\/p>\n<pre class=\"brush:bash\">show databases;\r\n<\/pre>\n<p>The same operation can be performed with following Java code snippet as well:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Show Databases with Java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\/\/ print existing databases\r\nmongoClient.getDatabaseNames().forEach(System.out::println);\r\n<\/pre>\n<p>This will show the existing databases in the system:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Output<\/em><\/span><\/p>\n<pre class=\"brush:bash\">admin\r\nlocal\r\n<\/pre>\n<p>In above output, <code>local<\/code> is the default Mongo database.<\/p>\n<h3>7.3 Create a Collection<\/h3>\n<p>We can create a collection in our database by following Java code snippet:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>MongoApp.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\/\/ get database\r\nMongoDatabase jcgDatabase = mongoClient.getDatabase(\"JavaCodeGeeks\");\r\n\r\n\/\/ create collection\r\njcgDatabase.createCollection(\"authors\");\r\njcgDatabase.createCollection(\"posts\");\r\n<\/pre>\n<p>This is to be noticed that <strong>we never created the mentioned database<\/strong>. Still, MongoDB will <strong>not<\/strong> throw any error. It is optimistic and it understands that if a DB doesn&#8217;t exist, it will create one for you. If you run the show databases command again, we will see a different output this time:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Databases<\/em><\/span><\/p>\n<pre class=\"brush:bash\">JavaCodeGeeks\r\nadmin\r\nlocal\r\n<\/pre>\n<p>The database was automatically created.<\/p>\n<h3>7.4 Save \u2013 Insert into a collection<\/h3>\n<p>In MongoDB, insertion works a little differently than other databases. While inserting, if an id is present in the database, it updates the same document, otherwise, it performs an insert operation. If we try to save a new author which doesn&#8217;t exist in the database, insertion will happen:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Insertion<\/em><\/span><\/p>\n<pre class=\"brush:java\">MongoCollection&lt;Document&gt; authorCollection = jcgDatabase.getCollection(\"authors\");\r\nDocument document = new Document();\r\ndocument.put(\"name\", \"Shubham\");\r\ndocument.put(\"company\", \"JCG\");\r\ndocument.put(\"post_count\", 20);\r\nauthorCollection.insertOne(document);\r\nSystem.out.println(\"Inserted document = \" + document);\r\n<\/pre>\n<p>When we run this code snippet, we will see that an <code>_id<\/code> is automatically assigned to this object which we can later to update the same document in our code:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Output<\/em><\/span><\/p>\n<pre class=\"brush:bash\">Inserted document = Document{{name=Shubham, company=JCG, post_count=20, _id=5b77c15cf0406c64b6c9dae4}}\r\n<\/pre>\n<h3>7.5 Save &#8211; Update an existing document<\/h3>\n<p>Now that we have inserted a document in an existing collection in a database in our MongoDB, we can update it as we know its ID as well. We will perform an update operation with the following code snippet and update the author&#8217;s name:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Updating Document<\/em><\/span><\/p>\n<pre class=\"brush:bash\">\/\/Find existing document\r\nDocument updateQuery = new Document();\r\nupdateQuery.put(\"name\", \"Shubham\");\r\n\r\n\/\/Field to update\r\nDocument newNameDocument = new Document();\r\nnewNameDocument.put(\"name\", \"Shubham Aggarwal\");\r\n\r\n\/\/Perform set operation\r\nDocument updateObject = new Document();\r\nupdateObject.put(\"$set\", newNameDocument);\r\n\r\nUpdateResult updateResult = authorCollection.updateOne(updateQuery, updateObject);\r\nSystem.out.println(\"Documents updated: \" + updateResult.getModifiedCount());\r\n<\/pre>\n<p>When we run this code snippet, we will see that at least one document was correctly modified in database:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Output<\/em><\/span><\/p>\n<pre class=\"brush:bash\">Documents updated: 1\r\n<\/pre>\n<p>As we noticed, in this provided code snippet, save followed the convention of update, because we used an object with given <code>_id<\/code>.<\/p>\n<h3>7.6 Getting all documents in a collection<\/h3>\n<p>It is easy to find all documents present in a collection for which we just need to provide a query object on which filtering is done before documents are fetched from collections. Let&#8217;s see how this can be done with Java code snippet:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Get all documents<\/em><\/span><\/p>\n<pre class=\"brush:bash\">Document searchQuery = new Document();\r\nsearchQuery.put(\"company\", \"JCG\");\r\n\r\nFindIterable&lt;Document&gt; documents = authorCollection.find(searchQuery);\r\n\r\nfor (Document document: documents) {\r\n    System.out.println(document);\r\n}\r\n<\/pre>\n<p>We get following output once we run the above code:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Output<\/em><\/span><\/p>\n<pre class=\"brush:bash\">Document{{_id=5b77c15cf0406c64b6c9dae4, name=Shubham Aggarwal, company=JCG, post_count=20}}\r\n<\/pre>\n<p>There are many more operations which can be performed on a <code>FindIterable<\/code> object out of which, we will see some in coming sections.<\/p>\n<h3>7.7 Deleting a document<\/h3>\n<p>Deleting a document is easy. We just need to provide the filter query and work will be done.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:bash\">Document deleteSearchQuery = new Document();\r\ndeleteSearchQuery.put(\"_id\", new ObjectId(\"5b77c15cf0406c64b6c9dae4\"));\r\nDeleteResult deleteResult = authorCollection.deleteOne(deleteSearchQuery);\r\nSystem.out.println(\"Documents updated: \" + deleteResult.getDeletedCount());\r\n<\/pre>\n<p>We get following output once we run the above code:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Output<\/em><\/span><\/p>\n<pre class=\"brush:bash\">Documents updated: 1\r\n<\/pre>\n<p>Notice that we used the value of ID not as a <code>String<\/code> but as an <code>ObjectId<\/code> because that is what MongoDB understands. Although, it is completely possible to use a simple String as an ID as well, but other types are not supported for identification fields. Finally, notice that we used <code>deleteOne<\/code> method which deletes only a single document. Even if MongoDB finds more than one document for the provided filter (in case of ID, it cannot find more than one but possible in other cases), it would have still deleted just one document from them (the first matched document is deleted). To delete all the filtered documents, we can use <code>deleteMany<\/code> method.<\/p>\n<h2>8. The _id field Decoded<\/h2>\n<p>Every MongoDB document has an <code>_id<\/code> field which is an unique identifier for a given document in a collection. It looks something like:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>_id<\/em><\/span><\/p>\n<pre class=\"brush:bash\">{\r\n    \"_id\" : ObjectId(\"5b77c15cf0406c64b6c9dae4\")\r\n    ... other fields ...\r\n}\r\n<\/pre>\n<p>Many a times, people (definitely not developers) think that is a randomly generated token of String which is carefully chosen so that it remains unique across any number documents saved in this collection. But this is not the case. Each _id of all documents in MongoDB is a 12-byte hexadecimal number that ensures the uniqueness of the document in a collection. It is generated by MongoDB if not provided by the developer himself (in which case the meaning of that String will completely change but still remain the unique identifier in the collection).<\/p>\n<p>Of the 12 bytes, the initial 4 bytes depicts the current timestamp, the following 3 bytes presents the machine identifier, the next 2 bytes describes the process ID for the MongoDB server on this machine, and the last 3 bytes are simple auto-increment counter maintained by MongoDB server. This can also be explained with a simple diagram:<\/p>\n<p><figure id=\"attachment_80809\" aria-describedby=\"caption-attachment-80809\" style=\"width: 561px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/mongodb.png\"><img decoding=\"async\" class=\"wp-image-80809 size-full\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/mongodb.png\" alt=\"MongoDB Tutorial - _id field decoded\" width=\"561\" height=\"281\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/mongodb.png 561w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/mongodb-300x150.png 300w\" sizes=\"(max-width: 561px) 100vw, 561px\" \/><\/a><figcaption id=\"caption-attachment-80809\" class=\"wp-caption-text\">_id field decoded<\/figcaption><\/figure><\/p>\n<p>This field also represents the primary key of each document in a MongoDB collection.<\/p>\n<h2>9. Limitations of MongoDB<\/h2>\n<p>Although MongoDB can scale a lot and has super-fast indexes, it also has some possible disadvantages. We used the term &#8220;possible&#8221; as this might or might not be a disadvantage for your use-case. Let&#8217;s see some of these disadvantages here:<\/p>\n<ul>\n<li>The maximum size which each document can occupy is 16MB.<\/li>\n<li>The maximum document-nesting level in a MongoDB document is 100<\/li>\n<li>The database name is limited to 64 characters<\/li>\n<li>If we apply an index on any field, that field value cannot contain more than 1024 bytes<\/li>\n<li>A hashed index cannot be unique<\/li>\n<li>You cannot rollback automatically if data is more than 300 MB. Manual intervention is needed in such cases<\/li>\n<\/ul>\n<p>As we mentioned, these are some disadvantages which might never occur in your application and you won&#8217;t have to do anything for the same.<\/p>\n<h2>10. MongoDB vs RDBMS<\/h2>\n<p>The battle of MongoDB and RDBMS databases is never-ending. Developers always have a long debate over which one is faster or better than the other but the answer is, there is no comparison between the two because of use-cases under which each of these are used. To mention, let&#8217;s describe the advantages of MongoDB over RDBS databases here:<\/p>\n<ul>\n<li>Collections in the MongoDB database are <strong>schemaless<\/strong>. Documents inserted in collections can have different sets of fields without having to do anything extra at the application level or database level.<\/li>\n<li>MongoDB has rich query support. MongoDB supports dynamic queries on a database.<\/li>\n<li>Conversion or mapping between database objects and application objects is simple as most of the application supports JSON mapping with database objects.<\/li>\n<li>Integrated memory support allows the user to access data in a much faster way.<\/li>\n<\/ul>\n<p>MongoDB is not magically faster. If you store the same data, organised in basically the same fashion, and access it exactly the same way, then you really shouldn&#8217;t expect your results to be wildly different. After all, MySQL and MongoDB are both GPL, so if Mongo had some magically better IO code in it, then the MySQL team could just incorporate it into their codebase.<\/p>\n<p>People are seeing real-world MongoDB performance largely because MongoDB allows you to query in a different manner that is more sensitive to a workload. For example, consider a design that persisted a lot of information about a complicated entity in a normalised fashion. This could easily use dozens of tables in MySQL (or any relational database) to store the data in a normal form, with many indexes needed to ensure relational integrity between tables.<\/p>\n<p>Now consider the same design with a document store. If all of those related tables are subordinate to the main table (and they often are), then you might be able to model the data such that the entire entity is stored in a single document. In MongoDB, we can store this as a single document, in a single collection. This is where MongoDB starts enabling superior performance.<\/p>\n<h2>11. Conclusion<\/h2>\n<p>In this lesson, we quickly got acquainted to using MongoDB in a simple maven-based Java application and performed CRUD operations on our collections with an updated API.<\/p>\n<p>We also studied various advantages of MongoDB. Though there can be many use-cases in which you will want to use MongoDB over a SQL database, I think <strong>Schema flexibility is most probably the most important factor<\/strong> which affects this decision. MongoDB provides us with an ability to store data or documents in a collection which can have different fields which can help a lot during the development phase of an application but also in ingesting data from multiple sources that may or may not have the same properties and schema associated with them. In comparison with an RDBMS database where columns have to be predefined and having sparse data can be penalized, in MongoDB this is the norm and it&#8217;s a feature that most use cases share. Having the ability to deep nest attributes into documents, add arrays of values into attributes and all the while being able to search and index these fields helps application developers exploit the schema-less nature of MongoDB.<\/p>\n<p>Finally, Scaling and sharding are the most common patterns for MongoDB use cases. Easily scaling using built-in sharding and using replica sets for data replication and offloading primary servers from read load can help developers store data effectively. Even apart from the advantages MongoDB offers, MongoDB still has some critics which mention that scale is not something we need in every application and so, nullifying the one of the most important factors which favours MongoDB.<\/p>\n<h2>12. Download the Source Code<\/h2>\n<p>This was a\u00a0MongoDB Tutorial with Java programming language.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <strong><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JCG-JavaMongoDB-Example.zip\" target=\"_blank\" rel=\"noopener\">MongoDB Example<\/a><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction to MongoDB In this post, we feature a comprehensive MongoDB Tutorial that integrates with a Java-based application. Whenever we read about NoSQL databases, we need to know why were they ever developed when SQL databases were working excellent. NoSQL foundations grew upon relaxed ACID (atomicity, consistency, isolation, durability) guarantees in favour of performance, &hellip;<\/p>\n","protected":false},"author":20016,"featured_media":187,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[428,1200,112,113],"class_list":["post-80792","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-database","tag-java","tag-mongodb","tag-nosql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MongoDB Tutorial for Beginners - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn more about MongoDB? Then check out our detailed MongoDB Tutorial! MongoDB is an open-source, document-oriented, cross-platform DB.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MongoDB Tutorial for Beginners - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about MongoDB? Then check out our detailed MongoDB Tutorial! MongoDB is an open-source, document-oriented, cross-platform DB.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-21T04:00:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Shubham Aggarwal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shubham Aggarwal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"16 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/08\\\/mongodb-tutorial-for-beginners.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/08\\\/mongodb-tutorial-for-beginners.html\"},\"author\":{\"name\":\"Shubham Aggarwal\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/0953481a8babbb7a63907edb41f357ad\"},\"headline\":\"MongoDB Tutorial for Beginners\",\"datePublished\":\"2018-08-21T04:00:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/08\\\/mongodb-tutorial-for-beginners.html\"},\"wordCount\":2763,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/08\\\/mongodb-tutorial-for-beginners.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mongodb-logo.jpg\",\"keywords\":[\"Database\",\"Java\",\"MongoDB\",\"NoSQL\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/08\\\/mongodb-tutorial-for-beginners.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/08\\\/mongodb-tutorial-for-beginners.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/08\\\/mongodb-tutorial-for-beginners.html\",\"name\":\"MongoDB Tutorial for Beginners - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/08\\\/mongodb-tutorial-for-beginners.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/08\\\/mongodb-tutorial-for-beginners.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mongodb-logo.jpg\",\"datePublished\":\"2018-08-21T04:00:34+00:00\",\"description\":\"Interested to learn more about MongoDB? Then check out our detailed MongoDB Tutorial! MongoDB is an open-source, document-oriented, cross-platform DB.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/08\\\/mongodb-tutorial-for-beginners.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/08\\\/mongodb-tutorial-for-beginners.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/08\\\/mongodb-tutorial-for-beginners.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mongodb-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mongodb-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/08\\\/mongodb-tutorial-for-beginners.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"MongoDB Tutorial for Beginners\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/0953481a8babbb7a63907edb41f357ad\",\"name\":\"Shubham Aggarwal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g\",\"caption\":\"Shubham Aggarwal\"},\"description\":\"Shubham is a Java EE Engineer with about 3 years of experience in building quality products with Spring Boot, Spring Data, AWS, Kafka, PrestoDB.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sbmaggarwal\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/shubham-aggarwal\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MongoDB Tutorial for Beginners - Java Code Geeks","description":"Interested to learn more about MongoDB? Then check out our detailed MongoDB Tutorial! MongoDB is an open-source, document-oriented, cross-platform DB.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html","og_locale":"en_US","og_type":"article","og_title":"MongoDB Tutorial for Beginners - Java Code Geeks","og_description":"Interested to learn more about MongoDB? Then check out our detailed MongoDB Tutorial! MongoDB is an open-source, document-oriented, cross-platform DB.","og_url":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-08-21T04:00:34+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","type":"image\/jpeg"}],"author":"Shubham Aggarwal","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Shubham Aggarwal","Est. reading time":"16 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html"},"author":{"name":"Shubham Aggarwal","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/0953481a8babbb7a63907edb41f357ad"},"headline":"MongoDB Tutorial for Beginners","datePublished":"2018-08-21T04:00:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html"},"wordCount":2763,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","keywords":["Database","Java","MongoDB","NoSQL"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html","url":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html","name":"MongoDB Tutorial for Beginners - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","datePublished":"2018-08-21T04:00:34+00:00","description":"Interested to learn more about MongoDB? Then check out our detailed MongoDB Tutorial! MongoDB is an open-source, document-oriented, cross-platform DB.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-tutorial-for-beginners.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"MongoDB Tutorial for Beginners"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/0953481a8babbb7a63907edb41f357ad","name":"Shubham Aggarwal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g","caption":"Shubham Aggarwal"},"description":"Shubham is a Java EE Engineer with about 3 years of experience in building quality products with Spring Boot, Spring Data, AWS, Kafka, PrestoDB.","sameAs":["https:\/\/www.linkedin.com\/in\/sbmaggarwal\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/shubham-aggarwal"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/80792","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/20016"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=80792"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/80792\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/187"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=80792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=80792"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=80792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}