6 Replies Latest reply on Nov 13, 2007 6:14 AM by Pete Muir

    editing part of a business key with seam framework

    koen handekyn Newbie

      is there a way to allow editing of a composite PK parts with the seam CRUD framework?

      i have a class with a composite key path and name as elements. i have written a faces converter that converts the PK class to and from a string representation.

      i can list and open the instances for edting, updating the PK fields does not work !!!

      thanx for the comments.

      koen handekyn

        • 2. Re: editing part of a business key with seam framework
          koen handekyn Newbie

          the 'details' view opens fine, make a change to the one part of key value (name for example).

          press the standard 'update' button (triggering the update method on the home component. update success is presented (as a faces message),

          pushing the 'done' button brings you back to the list view, but the values belonging to the composite key don't update.

          so NO visible 'issues' but the update for the key fields don't seem to get triggered.

          it's not critical, I turned back to an artificial ID field, and defined a composite uniqueConstraint for the business identity colums of the business composite key. but i would like to understand the issue.

          for clarity, it's not a generic seam question, but a question relating to the seam EntityHome base class as far as i can trace. are there examples with composite business keys getting manipulated with the EntityHome base classes that I missed?

          thanx

          • 3. Re: editing part of a business key with seam framework
            koen handekyn Newbie

            the 'details' view opens fine, make a change to the one part of key value (name for example).

            press the standard 'update' button (triggering the update method on the home component. update success is presented (as a faces message),

            pushing the 'done' button brings you back to the list view, but the values belonging to the composite key don't update.

            so NO visible 'issues' but the update for the key fields don't seem to get triggered.

            it's not critical, I turned back to an artificial ID field, and defined a composite uniqueConstraint for the business identity colums of the business composite key. but i would like to understand the issue.

            for clarity, it's not a generic seam question, but a question relating to the seam EntityHome base class as far as i can trace. are there examples with composite business keys getting manipulated with the EntityHome base classes that I missed?

            thanx

            • 4. Re: editing part of a business key with seam framework
              Pete Muir Master

              Do the setters on the composite key get called?

              • 5. Re: editing part of a business key with seam framework
                koen handekyn Newbie

                i totally redid the job with a clean entity bean and clean home and query components.

                i have put log statements in the setters for the composite key fields and can CONFIRM that they are called

                it should be noted that the 'not updating" issue only apears for changing field values. i can perfectly use the standard pages to CREATE a new entity.

                more strange behaviour: when i update both a key field and another field at the same time : i DO get an exception:

                Caused by: javax.persistence.OptimisticLockException: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row
                count: 0; expected: 1
                 at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:654)
                 at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:600)
                 at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:525)
                 at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
                 at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
                 at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
                 at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
                 at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1382)
                 ... 49 more
                Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
                 at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
                 at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
                 at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
                 at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
                 at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
                 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
                 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
                 at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
                 at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
                 at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
                 at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
                 at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:516)
                 ... 54 more


                • 6. Re: editing part of a business key with seam framework
                  Pete Muir Master

                  This is a hibernate question - try asking over on the hibernate forum :)