What is the correct way to eager fetch a nested collection in ebean and Play Framework 2? I tried this:
Registration registration = find
.fetch("participants")
.fetch("participants.fieldValues")
.fetch("participants.fieldValues.field")
.where().eq("token", token).findUnique();
For some reason registration.participants.fieldValues.field
objects only have an id. The rest of the field
properties are null. E.g. field.name
is null when it should have a value.
Edit:
If I make Field.name private and add a getter/setter for it, then I can get its value. But since I'm using fetch("participants.fieldValues.field")
shouldn't that make it eager fetch without needing the getter/setter?
Magic that does not work is a waste of time for everybody. I have had numerous issues with genrated getters and setters. Some also related to referencing models in templates. I created getters and setters and kept fields private for my ebean models and never looked back.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With