MongoDB is a document-oriented NoSQL database that stores application data as JSON-like documents rather than relational rows. In Quarkus, the Panache integration maps Java entities to MongoDB documents while retaining a familiar persistence style. section 7.6
Integrating MongoDB with Panache follows a short application setup:
- Add the quarkus-mongodb-panache extension and configure the connection string and database. section 7.6.1
- Define an entity by extending PanacheMongoEntity, or use PanacheMongoEntityBase when declaring a custom identifier. section 7.6.1
- Use PanacheMongoRepository or PanacheMongoRepositoryBase when applying the repository pattern. section 7.6.1
- Use Dev Services during development when the production connection property is undefined. section 7.6.1
Persisting rental documents
A Rental entity can store userId, reservationId, dates, and an active flag. A start endpoint creates and persists a rental; an end endpoint finds it by userId and reservationId, updates its state, and returns the document. A listActive method queries active rentals. MongoDB transactions are available from version 4.0 but are not required for this flow. section 7.6.2
Listing 7.26 Adding quarkus-mongodb-panache extension
$ quarkus ext add quarkus-mongodb-panache Looking for the newly published extensions in registry.quarkus.io [SUCCESS] ✅ Extension io.quarkus:quarkus-mongodb-panache has been installed
Use the extension command as the starting point for enabling MongoDB Panache in a Quarkus service. section 7.6.1
MongoDB uses ObjectId identifiers through PanacheMongoEntity rather than numeric IDs. Services exchanging these entities must account for the identifier becoming a String in serialized responses and client-side models. section 7.6.3






