-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Results from Queries update persistence context.
PostPosted: Tue Jul 03, 2007 11:54 am 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.