Panache MongoDB integrates MongoDB persistence into a Quarkus service through the quarkus-mongodb-panache extension. The implementation follows a short path: install the extension, configure the connection, define entities, and optionally add repositories. section 7.6.1
Configure the persistence layer with these decisions:
- Provide the MongoDB connection string; also configure the database name unless entities specify it with @MongoEntity. section 7.6.1
- Extend PanacheMongoEntity for an automatically supplied identifier, or PanacheMongoEntityBase when declaring a custom identifier. section 7.6.1
- Use PanacheMongoRepository or PanacheMongoRepositoryBase when choosing the repository pattern or changing identifier types. section 7.6.1
Persisting rentals through an active-record entity
A Rental entity stores userId, reservationId, dates, and active state. Static methods find a rental by user and reservation or list active rentals. A REST resource creates a rental, calls persist(), then updates and persists an existing rental when ending it.
Development mode starts MongoDB through Dev Services when the production connection property is undefined. Verify the service with HTTP requests or inspect the stored document using mongosh; a fixed Dev Services port is optional. section 7.6.2
