Hi,
I have a 1:M rel between Company and Employee.
A company in memory has no employees. But the same company in the database does have employees.
If a query is issued to retrieve these employees using an EntityManager, a list of employees is returned.
However, the in memory reference to the same company which is attached to the same entity manager which issued the queried still has no employees even after the query has been issued.
I would have that after the query has been issued the company's employees would have been updated but they are not.
In pseudo code:
Code:
// get employees
em.merge(company); // ensure company is attached to em
company.getEmployees().size(); // will output zero
// the eemployees query
List employees = employeesQuery.getResultList();
System.out.println("employees size="+ employees.size()); // outputs 5
// Now see if the attached company has been updated
company.getEmployees().size(); // will still output 0