From: Mike A. (JIRA) <nh...@gm...> - 2011-07-01 18:06:52
|
StaleStateExceptions discarded on optional <join> table ------------------------------------------------------- Key: NH-2785 URL: http://216.121.112.228/browse/NH-2785 Project: NHibernate Issue Type: Bug Components: Core Affects Versions: 3.1.0 Reporter: Mike Abraham Priority: Major When extending an existing table via an optional <join> (see abridged mapping below) and specifying optimistic locking via optimistic- lock="dirty" dynamic-update="true" (since <version> cannot be used in a <join>), updates to existing records in the join table that have been modified by another user, correctly throw a StaleStateException. However, the exception is caught and discarded because IsNullableTable is true (because the <join> is optional) in the following code from AbstractEntityPersister. protected bool Check(int rows, object id, int tableNumber, IExpectation expectation, IDbCommand statement) { try { expectation.VerifyOutcomeNonBatched(rows, statement); } catch (StaleStateException) // THE StaleStateException IS THROWN { if (!IsNullableTable(tableNumber)) // ... BUT IS DISCARDED HERE { 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> -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |