-
Notifications
You must be signed in to change notification settings - Fork 693
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
One-To-Many Reference is null - But shouldn't be null #1497
Comments
Same issue here. In fact, if I write |
Did some more troubleshooting. Looks like the association is only available in the transaction.
The above outputs:
I can only assume this is not the desired behaviour? |
@orangethunder @daniel-reinhold Basically, Accessing Entity (Create, Read) must be done inside Transaction. This is because LAZY is basically mapped to relationship. If you change this to EAGER, it's probably not null outside of the transaction. But this is not recommended. It is more effective to JOIN each query than this. |
@heli-os, it behaves this way even if I change it to I did some more googling and it turns out it's a design limitation, see #656 (comment). So I think this issue can be closed, but perhaps it would be better if an exception is thrown when trying to access an association outside of a transaction, rather than just returning null. |
Just a guess. Can you make sure the User table has one row and that row has a UserPermission referenced, and then try again? |
Hi @daniel-reinhold, could you please try this? |
I have two tables:
User:
UserPermissions:
Now, when I query a User (e.G. UserEntity.findById(1)) and want to access the permissions, I get following exception:
What is the problem? I don't think that I missconfigured anything. Is it a bug?
The text was updated successfully, but these errors were encountered: