3 Replies Latest reply on Dec 11, 2005 2:47 PM by Gavin King

    Updating changes to an entity in a conversation bean.

    ryan dewell Novice

      I'm missing something very basic here. I'm using the Seam managed extended persistence + a conversation scoped bean. It's a very simple form that updates values on an existing entity.

      In my @Begin method, I load up the entity and store it the conversation bean. The subsequent view shows the current properties of that entity.

      A save button on my form hits the "save" method which has an @End annotation. Within the @End annotated save method, I call entityManager.merge(existing)...

      Nothing. No errors, no nothing. The view is redisplayed with the newly updated values.. but the database isn't getting updated with the changes. Navigating back to the (resetting the whole process), just gives me back an entity with the old values.

      Is this the right procedure for updating an existing entity in an conversation bean? I'm missing something basic but crucial here.

      Ryan

        • 1. Re: Updating changes to an entity in a conversation bean.
          Gavin King Master

          Flush-before-completion must be enabled. (It is actually a bug that it is not enabled by default in HEM.)

          You DO NOT have to call merge.


          Use a persistence.xml something like this:




          <entity-manager>
           <name>entityManager</name>
           <provider>org.hibernate.ejb.HibernatePersistence</provider>
           <jta-data-source>java:/DefaultDS</jta-data-source>
           <properties>
           <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
           <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
           <property name="hibernate.transaction.flush_before_completion" value="true"/>
           <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
           <property name="hibernate.show_sql" value="true"/>
           </properties>
          </entity-manager>


          • 2. Re: Updating changes to an entity in a conversation bean.
            ryan dewell Novice

            Ah, I'm not insane! Thanks for the quick response. I didn't think merge was necessary either. I'll try this right away.

            Ryan

            • 3. Re: Updating changes to an entity in a conversation bean.
              Gavin King Master

              Ooops, I forgot:

              There is more you need to do. There is actually a bug in the currently released version of HEM that causes it to not get enlisted in the JTA txn in some circumstances.

              Emmanuel is waiting for Steve to release HB 3.1 before he can release the next version of HEM/HA. That will happen sometime this week (Monday/Tuesday).

              In the meantime, you can build HB/HEM/HA from current CVS.

              You then need to upgrade JBoss 4.0.3 to use these fixed versions of HB/HEM/HA.

              phew.

              (By the way, after you do all this stuff, it really *does* work, I promise.)