Skip to content

Support Spring Data @Reference annotation [DATAMONGO-915] #1839

Closed
@spring-projects-issues

Description

@spring-projects-issues

David Rauschenbach opened DATAMONGO-915 and commented

There's currently no support for manually loaded lazy references.

@DBRef is a bit of a mess right now for a few reasons:

  1. Big systems don't use it, because it wastes storage space for no good reason. The exception being when db is not blank, for a cross-database reference.

  2. It triggers some drivers to eager-load, but that's not always what is always wanted. A developer might really rather manually deference a field to trigger the lazy load, especially if it is a big database or a realtime capped collection tailing use case. In my opinion the Mongo Spring Data driver really MUST provide a single-query option for loading a doc with reference fields.

  3. It requires Mongo-specific annotations, and doesn't inherit some of the reasonable Spring Data or JPA annotations that people will be using who are writing systems that have heterogeneous DB support, like @Reference or @Embedded hints.

The Spring Data @Reference annotation is an opportunity to deal with some of these things. It could become the means by which a simple ObjectId() is written into the DB


Affects: 1.4.2 (Codd SR2)

3 votes, 3 watchers

Metadata

Metadata

Assignees

Labels

in: mappingMapping and conversion infrastructuretype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions