-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Configuration
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Currently, users must specify three configuration properties:
hibernate.dialect=MongoDB
hibernate.connection.provider_class=mongodb
jakarta.persistence.jdbc.url=mongodb://localhost/mydb
Since the dialect and connection provider always go together with a MongoDB URL, both can be inferred automatically, reducing the required configuration to:
jakarta.persistence.jdbc.url=mongodb://localhost/mydb
Proposed implementation
Add inference logic to MongoStrategyContributor.contribute(), which is invoked for every Hibernate bootstrap before any service initiators run, making auto-applied settings visible to DialectFactory and ConnectionProviderInitiator when they subsequently run.
Two inference rules, applied in order:
- If jakarta.persistence.jdbc.url starts with mongodb:// or mongodb+srv:// and hibernate.dialect is not set, auto-set hibernate.dialect=MongoDB.
- If hibernate.dialect=MongoDB (whether set explicitly or inferred from the URL) and hibernate.connection.provider_class is not set, auto-set hibernate.connection.provider_class=mongodb and register MongoConnectionProvider in the StrategySelector.
Acceptance criteria
- Setting only jakarta.persistence.jdbc.url=mongodb://... is sufficient to bootstrap without error.
- Setting only hibernate.dialect=MongoDB (plus a URL) auto-selects the connection provider.
- Explicit configuration of either setting is still respected and unchanged.
- Non-MongoDB sessions are unaffected.
- is related to
-
HIBERNATE-137 Feature: Improved Spring Data/Boot Integration
-
- Needs Triage
-