1 Reply Latest reply on Jan 7, 2007 1:39 AM by norman.richards

    End conversation context

    Yevgen Bushuyev Newbie

      I can't understand why conversation context is not deleted when method annotated as @End is being called. Here is the code:

      public class EditSomething implements EditSomethingLocal {
       EntityManager em;
       SessionContext ctx;
       Context sessionContext;
       Something something;
       FacesMessages facesMessages;
       public void prepare(){
       public void create(){
       public void remove(){

      form to create:
       <table border="0">
       <td class="cntForm">Name</td>
       <td class="cntForm">
       <h:inputText id="name" required="true" value="#{something.name}">
       <s:validate />
       </h:inputText> *
       <td><h:message for="name" styleClass="cntError" /></td>
       <h:commandButton action="#{editSomething.create}" value="Create" />

      The first entity is created ok, but when then the form is displayed the input field contains name of the created item, and when Create button pushed secnod time i'm getting

      javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist

      that's clear - since context was not destroyed the entity stored in it got detached and when again was passesed to persist causes exception. But according to seam docs

      When an @End method is encountered, any long-running conversation context is demoted to a temporary conversation


      At the end of the restore view phase of the JSF request lifecycle, Seam attempts to restore any previous long-running conversation context. If none exists, Seam creates a new temporary conversation context.

      Thus, if existing contex was demoted to temporary one seam should create new temporary conversation context (and create new Something in it!) which in it's turn should be promoted to the long running conversation when prepare() is called...

      What do i miss?

      wbr, eugen.