posted 4 years ago
Hello everyone, i am trying to make a simple database using JPA, and i just can't figure out what i'm doing wrong. I have two entites, Account and Person, where one Person can have many accounts, and one account can only have one person. My problem is that the list i use in Person to store the account is never initialized. I know it is initialized when fed to the database, and when i query the database i get data returned as expected, except the ArrayList<Account> account, which is always null. Can anyone please help me out?
Person entity:
Account entity:
EntityManager:
I can add more code if necessary, but hopefully it is enough. If i now add a person:
And query this person, i get all relevant data - except the accounts list, which is null. Any idea why?