Files
spring-data-examples/mongodb/linking
Marc Wrobel ce994f9ea0 Fix typos in documentations.
Fix typos in READMEs, javadoc, comments and code.

Original pull request #642
2022-07-29 13:07:11 +02:00
..
2022-07-29 13:07:11 +02:00
2022-05-19 11:23:00 -05:00

Spring Data MongoDB - Linking Example

This project contains examples for linking Documents using:

  • @DBRef
  • @DocumentReference

DBRef

Use MongoDB native dbref for storing associations.

class Manager {
	
    @DBRef
    private List<Employee> employees;

    // ...
}

DocumentReference

Link documents via their id.

class Manager {
	
    @DocumentReference
    private List<Employee> employees;

    // ...
}

Link documents via a (non id) property.

class Manager {
	
    @DocumentReference(lookup = "{ 'name' : ?#{#target} }")
    private List<Employee> employees;

    // ...
}

Link documents JPA style.

class Manager {

    @ReadOnlyProperty
    @DocumentReference(lookup="{'managerId':?#{#self._id} }")
    private List<Employee> employees;

    // ...
}

For more information please refer to the Reference Documentation.