-
Notifications
You must be signed in to change notification settings - Fork 367
Consider embedded properties in the QBE queries #2100
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
Conversation
6d9d098
to
6985e8c
Compare
Signed-off the commits
3d8fa6e
to
a7f08ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR goes into the right direction. There's quite some noise and parameter and variable names are quite lengthy. Long names add complexity and from my perspective, they do not improve readability or understandability by explaining different domains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we don't distinguish based on whether the property is an embedded one but rather whether it is an entity. At some point it should be possible to express criteria based across objects that are part of the aggregate (like it is done in JPA, we consider embeddables and references).
.../main/java/org/springframework/data/relational/repository/query/RelationalExampleMapper.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason behind the renaming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because one can confuse the PersistenceEntity
with the entity
as the actual instance/probe. I do not insist here at all, just my observation when working with code, what do you think, @mp911de ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually do like the rename and the idea behind it.
.../main/java/org/springframework/data/relational/repository/query/RelationalExampleMapper.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Use a for-loop instead of callback-style to reduce stack frames.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a duplication of the general code that collects criteria for example matching. Should be consolidated.
...rties in QBE Signed-off-by: mipo256 <mikhailpolivakha@gmail.com> Signed-off-by: Михаил Поливаха <mikhail.polivakha@gazprombank.ru>
a7f08ef
to
720e033
Compare
@mp911de Just to make sure that we're on the same page. The current version of the algorithm accounts for the deeply nested embedded objects, like:
@Table
class Root {
@Id
private Long id;
private String name;
@Embedded.Nullable
private EmbbedLevelOne levelone;
public static class EmbeddedLevelOne {
private String type;
@Embedded.Nullable
private EmbeddedLevelTwo levelTwo;
}
}
The problem is that if we unroll the recursion into the for-loop, then the code may get a bit messy, since this is not a tail-recursive function we're dealing with. I've tinkered with it, and the only sensible approach I found is to flatten-out all the properties of all the embedded objects (included deeply embedded) on demand, and store them in some kind of Queue
that we can iterate through and then just perform the checking.
I'm unsure that this is the best solution. From my personal, empirical data, I may humbly conclude that objects. Therefore the call stack will probably not be large at all. But again, this is merely my observation.
Now, having said that, I can push the for-loop like approach with Queue and we'll have a look. WDYT, @mp911de, @schauder ?
The problem is that if we unroll the recursion into the for-loop, then the code may get a bit messy, since this is not a tail-recursive function we're dealing with.
I think you are beyond what @mp911de asked for. His ask was just replacing the
persistentEntity.doWithProperties((PropertyHandler<RelationalPersistentProperty>) property -> { // ... }
With a for loop:
for (RelationalPersisntentProperty property : persistentEntity) { // .... }
Not an unrolling of the recursion.
The doWithProperties
creates one extra frame on the call stack.
Closes #2099
Closes #1986
This PR enhances the
RelationalExampleMapper
by making it consider embedded properties and specifiers for them.As it turned out during resolution of #1986, the embedded properties were kind of ignored in QBE.
Current algorithm works more a less the same way, it just traverses the
Example
recursively from direct properties defined in the rootprobe
, all the way down to the deeply embedded leafs.Tests are included in the PR.
CC: @mp911de @schauder