This content has been marked as final.
Show 2 replies
-
1. Re: Lazy loading problem
xtia004 Jan 21, 2007 7:28 PM (in response to xtia004)By further probing my code, I found it is actually caused by em.clear at another component. i.e. when I select a row at dataTable, the following code is executed:
InvoiceContacts invoiceContactsAction = (InvoiceContacts) Component.getInstance("invoiceContactsAction", ScopeType.SESSION); invoiceContactsAction.changeInvoice(getSelectedInvoice());
And code at component invoiceContactsAction is below:@Stateful @Name("invoiceContactsAction") @Scope(ScopeType.SESSION) public class InvoiceContactsAction implements InvoiceContacts { @PersistenceContext EntityManager em; ... public void changeInvoice(Invoice selectedInvoice) { this.selectedInvoice = selectedInvoice; tempList = null; invContacts = null; em.clear(); } ... }
So the question turn out to be: Why does clearing the entity manager at a component make the entity bean retrieved by another component detached under this situation? -
2. Re: Lazy loading problem
gavin.king Jan 21, 2007 10:00 PM (in response to xtia004)because there is a single persistence context for the whole transaction