-
1. Re: entityManager as argument?
zergspirit Jul 22, 2008 11:52 AM (in response to tszpinda)How do you declare your EntityManager? The error might occur because you're not using the Seam Managed Persistence Context (also refered as SMPC).
To have a SMPC, you need to do something like
@In
EntityManager entityManagerName
Where entityManagerName is declared in WEB-INF/component.xml like that<persistence:managed-persistence-context name="entityManagerName" ...
-
2. Re: entityManager as argument?
tszpinda Jul 22, 2008 2:58 PM (in response to tszpinda)in components.xml I have:
<persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/WebshopEntityManagerFactory"/>
Anyway just found my problem, I have created instance of Contact class in an authenticate method,
@Name(contact) @Entity public class Contact{ @ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.LAZY) @JoinColumn(name="customer_code", referencedColumnName="code", nullable=false) private Customer customer; }
and used @Out annotation to be able use it later:
@Out(required=false, scope = ScopeType.SESSION) private Contact contact;
but then when I try to call method doSearch:
@Begin(join=true) public String doSearch
and use in it:contact.getCustomer().getPriceLists(); //the price lists are fetched using the LAZY mode
I'm getting the error above. Could you suggest what would be the best approach?
- start the long running conversation in the authenticate method?
- or start it on doSearch() and reselect Contact from db?Thanks for your time, and sorry for my English.
Tomek
-
3. Re: entityManager as argument?
jacob.orshalick Jul 22, 2008 3:18 PM (in response to tszpinda)You could always merge the Contact into the SMPC when doSearch is invoked:
contact = entityManager.merge(contact);
or take a look at this alternative.
Hope it helps.
-
4. Re: entityManager as argument?
tszpinda Jul 22, 2008 8:22 PM (in response to tszpinda)Great, I tried first solution for now and it works!
Thanks