I have a legacy table, Case, which I am extending via a <join> (see
abridged mapping below) in a new application.  I want to use
optimistic locking so that if another user changes the joined CaseEx
table, I get a StaleObjectStateException.  Updates of stale data do
cause a StaleStateException to be thrown, but it is caught and
discarded because IsNullableTable is true in the following code from
AbstractEntityPersister.  Is this a bug or am I trying to do something
which is not supported?

                protected bool Check(int rows, object id, int tableNumber,
IExpectation expectation, IDbCommand statement)
                {
                        try
                        {
                                expectation.VerifyOutcomeNonBatched(rows, 
statement);
                        }
                        catch (StaleStateException)
                        {
                                if (!IsNullableTable(tableNumber))
                                {
                                        if 
(Factory.Statistics.IsStatisticsEnabled)
                                                
Factory.StatisticsImplementor.OptimisticFailure(EntityName);

                                        throw new 
StaleObjectStateException(EntityName, id);
                                }
                        }
                        catch (TooManyRowsAffectedException ex)
                        {
                                throw new HibernateException("Duplicate 
identifier in table for: "
+ MessageHelper.InfoString(this, id, Factory), ex);
                        }
                        catch (Exception)
                        {
                                return false;
                        }
                        return true;
                }


        <class name="Case" schema="Cases" table="`Case`" optimistic-
lock="dirty" dynamic-update="true">

                <id name="CaseId" >
                  <generator class="identity"/>
                </id>
                <property name="CaseCode"/>
                <property name="MarketingCaseCode"/>
                <property name="Name" column="CaseName"/>
                <property name="Status" column="StatusId"/>

                <join schema="CSA" table="CaseEx" optional="true">
                        <key column="CaseId"/>

                        <property name="Details"/>
                        <property name="Template"/>
                </join>
        </class>

Reply via email to