Consider embedded properties in the QBE queries
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 root probe, all the way down to the deeply embedded leafs.
Tests are included in the PR.
CC: @mp911de @schauder
Signed-off the commits
@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.
@mipo256 can you change it to the suggested for loop?
Sure @dschulten , I have already prepared necessary changes that address the review comments. I'll ping Mark and Jens once they are ready :)
Hey @mp911de, @schauder. I think, the PR is ready for the second round of review
@mp911de @schauder trying to nudge politely ;-)
Now that our GA release is done, we can finally continue over here.