Table of Contents Why MongoDB and Java are such good friendsThe missing schema of loosely typed systems Bringing schema back Example: Spring Boot sea temperature service Sea temperatures Weather reports Schemas Tip—BSON IDs and the _id field Traps—record definitions for POJO codec Data access Tip—typed queries with MongoCollection generics Trap—pagination …
-
Building REST APIs in Java with Spring Boot
Table of Contents How can Spring help?PrerequisitesCreating our appConnecting our databaseOur Book modelBook repositoryOur REST controllerCreateReadUpdateDeleteAdding DTOs and validationBookRequestBookResponseUpdating the controllerTesting the APIRun the APICreateReadUpdateDeleteConclusion REST has become the default choice for building web services, and for good reason. It’s …
-
MongoDB Aggregations: Organizing Recipes by Meal Type with $group
Table of Contents Why Use $group for Organizing Recipes?Setting Up the DataUsing $group to Organize Recipes by TypeStep 1: Grouping Recipes by TypeStep 2: Including Recipe Details in Each GroupGrouping Recipes by TagsStep 1: Using $unwind to Break Down TagsAdvanced …
-
Queryable Encryption With Spring Data MongoDB: How to Query Encrypted Fields
Table of Contents Why Queryable Encryption?A quick look at Spring Data MongoDBUse case: HR system with encrypted fieldsSetting up the projectConfiguring dependencies and propertiesAdding mongodb-cryptApplication.yml configurationAccessing properties in the codeBuilding the application layersThe domain modelThe repositoryThe serviceThe controllerSetting up encryptionConfiguring …
-
What happens when a Primary fails in a MongoDB replica set? Automatic failovers?
In distributed systems, high availability is not a luxury—it’s a necessity. And one of the very important parts of that is automatic failovers. What are automatic failovers and how do they work? Let’s see today! These concepts are actually similar …
-
Managing MongoDB Database Changes Using Liquibase Pro
Table of Contents What is Liquibase?What is MongoDB?Setting up a local MongoDB instance on WindowsUse Liquibase with MongoDBPrerequisitesInstall supporting driversConnection configurationConnection testHands-on execution steps detailed1. Create project and add files2. Project structure in VS Code3. Lifecycle of Liquibase4. Verify the …
-
Domain-Driven Design in Java: A Practical Guide
Table of Contents Understanding the “Airport” domainModeling the core Airport domain in JavaIdentifying aggregates and entitiesImplementing entities and value objectsBounded contexts and modularizationRepositories, domain services, and factoriesRepositoriesDomain servicesFactoriesApplication layer and integrationTesting and evolving the modelComplete DDD implementation source codeTesting scenarios …
-
Enforcing Governance in MongoDB Atlas with Resource Policies
Table of Contents What Are Resource Policies?Why Use Them?Available CapabilitiesApplying Resource Policies with Terraform🔐 Example 1: Allow clusters only on AWS🌐 Example 2: Block public IPs (0.0.0.0/0)🔒 Example 3: Enforce TLS 1.2 or higherValidation and Testing🚫 Attempt to create a …
-
Why Mirroring Production in Dev Helps You Avoid Costly Mistakes
Table of Contents The setup: A realistic aggregation scenarioThe application behind the testTesting on M0: The hidden riskTaking it to production: Same query, different outcomeReal-time metrics: Detecting the bottleneckQuery insights: The detective toolDon’t guess, let Performance Advisor show the wayResilience …
-
MongoDB ACID Transactions With Java
Table of Contents What are MongoDB ACID transactions and when should you use them?But do you really need a transaction?Transaction APIs: Callback vs coreWhen to use the callback APIWhen to use the core APISetting up: A simple banking examplePrerequisitesConnecting and …
-
How to Make a RAG Application With LangChain4j
Table of Contents Why use RAG?Use cases for RAGLangChain4J for RAGMongoDB for RAGPrerequisitesOur dependenciesSetting up MongoDB and our embedding storeMongoDB setupConfiguring the embedding storeCreating our embedding modelConfiguring our chat modelHow to load our dataParametersCreating our content retrieverAsking questionsConclusion Retrieval-augmented generation, …