Description
From this example:
------------------------------------------------------------------------------------------
<class-descriptor class="com.lear.app.sqs.beans.MyClass">
...
<collection-descriptor name="allUsers" collection-class="org.apache.ojb.broker.util.collections.ManageableArray
List" element-class-ref="com.lear.app.sqs.beans.MyUser"
auto-update="link"
indirection-table="CLASS">
<fk-pointing-to-this-class column="SPUNIT" />
<fk-pointing-to-this-class column="SPCLASS" />
<fk-pointing-to-element-class column="SPUNIT" />
<fk-pointing-to-element-class column="SPUSER" />
</collection-descriptor>
...
</class-descriptor>
---------------------------------------------------------------------------------------------------
Calling create(myClass) on Persistent Broker, when storing link for a collection it generates INSERT SQL with duplicated field SPUNIT -> results in SQL exception:
[org.apache.ojb.broker.accesslayer.StatementsForClassImpl] ERROR:
[SQL0121] Duplicate name SPUNIT not allowed.
INSERT INTO CLASS (SPUNIT, SPCLASS, SPUNIT,SPUSER) VALUES (?,?,?,?)
(OJB is trying to insert SPUNIT two times in one statement)
----------------------------------------------------------------------------------------------------------------------------
I am using OJB 1.0.3 and only used "link", didn't try "object". I made
a quick fix in MtoNBroker, that looks like it works for me now, please
see the attached file. And find it under "FIXED" comment,
OJB assumes that (M to N) table has only
different fields for M key and N key when actually in my case both
keys are composite and some fields are common.
M key: k1,m1
N key: k1,n1
So (M to N) table has only 3 keys: k1,m1,n1 , not 4: k1,m1,k1,n1.