Menu

#320 Can not obtain relations from several columns

v2.3.*
closed-fixed
Bug (232)
2.5.3
5
2016-05-22
2011-07-26
No

When you are trying to extract the relationship columns between tables, you can do it using ExportedKeysSearchCallback or ImportedKeysSearchCallback. These two classes extends from AbstractMetaDataBasedSearchCallback, which, in its function 'getNodes' obtains the edges which a table is related.
If we have the following tables

CREATE TABLE test(c1 integer, c2 integer, constaint pk_test primary key(c1, c2));
CREATE TABLE test2(c integer primary key, r1 integer, r2 integer, constaint fk_test2_to_test foreign key(r1,r2) references test(c1,c2));

in which we have several columns related, the function getNodes only obtains the first one. The problem here is that this function stores the result in a SortedSet object, which requires the 'compareTo' function to store the information. In AbstractMetaDataBasedSearchCallback, the edges are stored using the object ForeignKeyRelationshipEdge, which implements the 'equals' and 'hashCode' functions, but not the 'compareTo'. So, having all this into account, when several columns from the same table are tried to store in the SortedSet object, only the first will be stored, because these objects are compared internally as Edge objects (not as ForeignKeyRelationshipEdge).
To solve this problem only should implement the 'compareTo' function in the ForeignKeyRelationshipEdge class.
Regards.

Discussion

  • Jeff Jensen

    Jeff Jensen - 2016-05-22
    • status: open --> closed-fixed
    • assigned_to: matthias g --> Jeff Jensen
    • Fixed Release: --> 2.5.3
    • Found Release: --> v2.3.*
     
  • Jeff Jensen

    Jeff Jensen - 2016-05-22

    Thank you for the info.
    Added compareTo and test.

     

Log in to post a comment.