Antonio Fernández escribió:


Hi again !


-----------------------  EditInternalUser.java   ------------------------------------------------------------------------------------

public class EditInternalUser extends BaseEditPage<InternalUser,Integer> {

    @Mixin
    @SuppressWarnings("unused")
    private HibernateValidatorMixin hibernateValidatorMixin;

    @Inject
    private BeanModelSource beanModelSource;

    @Inject
    private Messages messages;

    @Override
    public BeanModel<InternalUser> getBeanModel() {
        return beanModelSource.createEditModel(InternalUser.class,messages);    (This method is overrided to show the @Id field in the form )
    }

}


-----------------------  EditInternalUser.tml   ------------------------------------------------------------------------------------

<html t:type="ApplicationLayout" title="message:admin.users.title"
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
      xmlns:p="tapestry:parameter">

    <div t:type="Zone" t:id="zone" xmlns="http://www.w3.org/1999/xhtml"
        xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
        <form t:type="Form" t:id="form" t:zone="prop:zone"
            accept-charset="UTF-8">

            <div t:type="crud/Message" t:message="message">
                Messages here.
            </div>
            <div t:type="Errors" t:id="errors" />

            <t:BeanEditor t:object="object" t:model="beanModel">

            </t:BeanEditor>

            <input type="submit" />
       </form>
    </div>
</html>

------------------------------------------------------------------------------------


I´m getting the following exception trace when a new InternalUser is inserted and the form is submitted :


-------------------------------------------------------------------------------------

What do you think about this error ?


Hi again,

The exception is throwed when the following method is executed from BaseEditPage.

    /**
     * Saves or updates an entity object. This implementation returns
     * <code>getController().saveOrUpdate(entity)</code>.
     *
     * @param entity a <code>T</code>. It cannot be null.
     * @return a <code>T</code>.
     */
    protected T saveOrUpdate(T entity) {
        return getController().saveOrUpdate(entity);
    }


Here is the log :


[TRACE] jdbc.ConnectionManager registering flush begin
[TRACE] entity.AbstractEntityPersister Updating entity: [org.agile2soft.nexoma.core.entity.InternalUser#amf]
[DEBUG] jdbc.AbstractBatcher about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[DEBUG] hibernate.SQL update INTERNAL_USER set USU_ATTEMPTS_NUMBER=?, USU_DOCUMENT=?, USU_DOCUMENT_NUMBER=?, USU_EMAIL=?, USU_EXTENSION=?, USU_JOB=?, USU_NAME=?, USU_PASSWORD=?, PER_ID=?, USU_SERVICES=?, USU_STATUS=?, USU_SURNAME1=?, USU_SURNAME2=? where USU_LOGIN=?
Hibernate: update INTERNAL_USER set USU_ATTEMPTS_NUMBER=?, USU_DOCUMENT=?, USU_DOCUMENT_NUMBER=?, USU_EMAIL=?, USU_EXTENSION=?, USU_JOB=?, USU_NAME=?, USU_PASSWORD=?, PER_ID=?, USU_SERVICES=?, USU_STATUS=?, USU_SURNAME1=?, USU_SURNAME2=? where USU_LOGIN=?
[TRACE] jdbc.AbstractBatcher preparing statement
[TRACE] entity.AbstractEntityPersister Dehydrating entity: [org.agile2soft.nexoma.core.entity.InternalUser#amf]
[TRACE] type.BooleanType binding 'true' to parameter: 1
[TRACE] type.BooleanType binding 'true' to parameter: 2
[TRACE] type.StringType binding 'myDocumentNumber' to parameter: 3
[TRACE] type.StringType binding 'my@mail.com to parameter: 4
[TRACE] type.StringType binding '2112' to parameter: 5
[TRACE] type.StringType binding '1234' to parameter: 6
[TRACE] type.StringType binding 'myname' to parameter: 7
[TRACE] type.StringType binding '1234' to parameter: 8
[TRACE] type.IntegerType binding '1' to parameter: 9
[TRACE] type.BooleanType binding 'true' to parameter: 10
[TRACE] type.BooleanType binding 'false' to parameter: 11
[TRACE] type.StringType binding '1234' to parameter: 12
[TRACE] type.StringType binding '1234' to parameter: 13
[TRACE] type.StringType binding 'Antonio' to parameter: 14
[DEBUG] jdbc.AbstractBatcher Executing batch size: 1
[ERROR] jdbc.AbstractBatcher Exception executing batch:
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:85)
    at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:70)
    at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:90)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)


Hibernate is generating an UPDATE statement when it´s should be an INSERT statement.


Thanks in advance & Greetings,
Antonio Fernández