-
Notifications
You must be signed in to change notification settings - Fork 1.1k
DATAMONGO-1902 - Add support for embedding objects. #896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In case we don't feel comfortable merging the related PR in Spring Data Commons (spring-projects/spring-data-commons#480), let's move forward by introducing a store-specific embedded-annotation and sort out the duplications in |
f7a29f1
to
ef12342
Compare
ef12342
to
dcf88bc
Compare
dcf88bc
to
c89d2e3
Compare
We now support embedded types in the sense of unwrapping nested objects into their parent Document to flatten out domain models where needed. A domain class of: public class User { @id private String userId; @Embedded(onEmpty = USE_NULL) private UserName name; } public class UserName { private String firstname; private String lastname; } renders: { "_id" : "1da2ba06-3ba7", "firstname" : "Emma", "lastname" : "Frost" }
Reorder API methods, remove unused MongoPersistentProperty.isNullable method, reduce visibility where possible. Add Javadoc and tweak documentation wording. Introduce DotPath utility to abstract dot path concatenation.
c89d2e3
to
3e00835
Compare
mp911de
pushed a commit
that referenced
this pull request
Feb 16, 2021
We now support embedded types in the sense of unwrapping nested objects into their parent Document to flatten out domain models where needed. A domain class of: public class User { @id private String userId; @Embedded(onEmpty = USE_NULL) private UserName name; } public class UserName { private String firstname; private String lastname; } renders: { "_id" : "1da2ba06-3ba7", "firstname" : "Emma", "lastname" : "Frost" } Resolves #2803. Original pull request: #896.
That's merged and polished now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on: spring-projects/spring-data-commons#2293
Embedded Types
Embedded entities are used to design value objects in your Java domain model whose properties are flattened out into the MongoDB Document.
Embedded Types Mapping
In the example below you see, that
User.name
is annotated with@Embedded
.The consequence of this is that all properties of
UserName
are folded into theuser
document.It is possible to use complex types within an embedded object.
However those must not be, nor contain embedded fields themselves.