-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
@DataJpaTest does not work against a MongoDB application using the MongoDB Hibernate Spring Boot starter.
Spring Boot's @DataJpaTest slice bootstraps a minimal JPA context by importing a fixed set of auto-configurations (HibernateJpaAutoConfiguration, DataSourceAutoConfiguration) and, by default, replaces the DataSource with an embedded SQL database via @AutoConfigureTestDatabase. Those are exactly the auto-configurations the starter excludes for a mongodb:// URL, and the slice imports them directly rather than going through the EnvironmentPostProcessor. The slice also does not include this module's MongoHibernateAutoConfiguration / MongoJpaRepositoriesAutoConfiguration. As a result, a @DataJpaTest against a MongoDB application builds the wrong (SQL) stack or fails outright.
The initial release (HIBERNATE-172) documents this as unsupported; users test repositories and entities with @SpringBootTest instead.
Proposed work: a dedicated test slice (e.g. @DataMongoHibernateTest) mirroring Spring Boot's JPA slice — a TypeExcludeFilter, an @ImportAutoConfiguration set targeting this module's auto-configurations, an AutoConfigure... registration in spring-boot-test-autoconfigure metadata, and transactional-rollback wiring — plus slice tests.
Follow-up to HIBERNATE-172 (see the design spec, "Limitations and Follow-ups").