OJB MtoN implementor failes to work properly with composite M & N keys that 
have some fields common.
----------------------------------------------------------------------------------------------------

         Key: OJB-76
         URL: http://issues.apache.org/jira/browse/OJB-76
     Project: OJB
        Type: Bug
  Components: PB-API  
    Versions: 1.0.3    
    Reporter: Sergey Manukyan


>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.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to