You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Bonnie MacKellar <BM...@mobius.com> on 2003/06/26 20:34:29 UTC
optimistic locking and decomposed M:N relationships
I am adding optimistic locking to my database, using integer version fields
in each table.
I notice that it does not seem to work with tables implementing M:N
relationships
(I am using the decomposed style). I get this error :
com.jnetdirect.jsql.w: Cannot insert the value NULL into column
'rowVersion', table 'ActiveBill.dbo.Custodian';
Custodian implements the M:N relationship between users and accounts.
Does this mean that I should omit the version fields in M:N relationship
tables?
How will locking be handled for such tables?
Here is the repository information for the tables in question :
<!-- Definitions for User table -->
<class-descriptor
class="com.mobius.activebill.persistentobjects.User"
table="ActiveBillUser"
>
<field-descriptor
name="userID"
column="userID"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
<field-descriptor
name="rowVersion"
column="rowVersion"
jdbc-type="INTEGER"
locking="true"
/>
... stuff omitted...
<collection-descriptor
name="accounts"
element-class-ref="com.mobius.activebill.persistentobjects.Account"
auto-retrieve="true"
auto-update="false"
indirection-table="Custodian"
>
<fk-pointing-to-this-class column="userID" />
<fk-pointing-to-element-class column="accountID" />
</collection-descriptor>
</class-descriptor>
!-- Definitions for Account table -->
<class-descriptor
class="com.mobius.activebill.persistentobjects.Account"
table="Account"
>
<field-descriptor
name="accountID"
column="accountID"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
<field-descriptor
name="rowVersion"
column="rowVersion"
jdbc-type="INTEGER"
locking="true"
/>
<field-descriptor
name="accountNumber"
column="accountNumber"
jdbc-type="VARCHAR"
/>
<field-descriptor
name="customerID"
column="customerID"
jdbc-type="INTEGER"
/>
<reference-descriptor
name="customer"
class-ref="com.mobius.activebill.persistentobjects.Customer"
proxy="true"
>
<foreignkey field-ref="customerID"/>
</reference-descriptor>
<collection-descriptor
name="users"
element-class-ref="com.mobius.activebill.persistentobjects.User"
auto-retrieve="true"
auto-update="false"
indirection-table="Custodian"
>
<fk-pointing-to-this-class column="accountID" />
<fk-pointing-to-element-class column="userID" />
</collection-descriptor>
<collection-descriptor
name="bills"
element-class-ref="com.mobius.activebill.persistentobjects.Bill"
proxy="true"
>
<inverse-foreignkey field-ref="accountID"/>
</collection-descriptor>
</class-descriptor>
<!-- Definitions for Custodian table -->
<class-descriptor
class="com.mobius.activebill.persistentobjects.Custodian"
table="Custodian"
>
<field-descriptor
name="accountID"
column="accountID"
jdbc-type="INTEGER"
primarykey="true"
/>
<field-descriptor
name="rowVersion"
column="rowVersion"
jdbc-type="INTEGER"
locking="true"
/>
<field-descriptor
name="userID"
column="userID"
jdbc-type="INTEGER"
primarykey="true"
/>
<reference-descriptor
name="user"
class-ref="com.mobius.activebill.persistentobjects.User"
auto-retrieve="false"
>
<foreignkey field-ref="userID"/>
</reference-descriptor>
<reference-descriptor
name="account"
class-ref="com.mobius.activebill.persistentobjects.Account"
auto-retrieve="false"
>
<foreignkey field-ref="accountID"/>
</reference-descriptor>
</class-descriptor>
thanks,
Bonnie MacKellar
software engineer
Mobius Management Systems, Inc.
bmackell@mobius.com