Menu

#71 Ambiguous table attribute declaration

open
nobody
None
5
2003-01-06
2003-01-06
No

last declaration of a table in build.xml will override table
attributes (singular, plural etc) Multiple declarations are
unavoidable in case of <many2many> and table
declaration in many2many overrides previous declaration
in <table> element. Even worse if you have multiple
<many2many> with the same table last declaration will
override previous one. If last declaration has no
attributes defined it will wipe out all previous declaratiois.
It makes it order sensitive and very messy

in this example DocketType3 class will be generated
<table name="COURT"/>
<table name="DOCKET_TYPE"
singular="DocketTypeT"/>

<many2many>
<tablea name="DOCKET_TYPE"
generate="true" singular="DocketType1"/>
<jointable name="DOCKET_TYPE_PRODUCT"
generate="false"/>
<tableb name="PRODUCT" generate="true"/>
</many2many>
<many2many>
<tablea name="DOCKET_TYPE"
generate="true" singular="DocketType2"/>
<jointable
name="DOCKET_TYPE_MILESTONE"
generate="false"/>
<tableb name="MILESTONE" generate="true"/>
</many2many>
<many2many>
<tablea name="DOCKET_TYPE"
singular="DocketType3"/>
<jointable name="DOCKET_TYPE_STATUS"
generate="false"/>
<tableb name="DOCKET_STATUS"/>
</many2many>

in this example DocketType class will be generated
(default name)instead of DocketTypeT
<table name="COURT"/>
<table name="DOCKET_TYPE"
singular="DocketTypeT"/>

<many2many>
<tablea name="DOCKET_TYPE"
generate="true" />
<jointable name="DOCKET_TYPE_PRODUCT"
generate="false"/>
<tableb name="PRODUCT" generate="true"/>
</many2many>
<many2many>
<tablea name="DOCKET_TYPE"
generate="true"/>
<jointable
name="DOCKET_TYPE_MILESTONE"
generate="false"/>
<tableb name="MILESTONE" generate="true"/>
</many2many>
<many2many>
<tablea name="DOCKET_TYPE"/>
<jointable name="DOCKET_TYPE_STATUS"
generate="false"/>
<tableb name="DOCKET_STATUS"/>
</many2many>

Discussion

  • Aslak Hellesřy

    Aslak Hellesřy - 2003-01-07

    Logged In: YES
    user_id=49846

    How would you suggest it would be declared to avoid such
    duplicate information?

     
  • Alex Roytman

    Alex Roytman - 2003-01-07

    Logged In: YES
    user_id=627656

    tables in many2many element should not carry any table
    specific attributes - they should only reference existing tables
    by name. Also it is logically cleaner if many2many element
    does not have "table declaration" functionality
    all table elements (if any) should be declared in table element
    if many2many references to some unexistent table it should
    give error at runtime. As a result one inconvenient situation
    will go away - I will not need to declare all my tables if they all
    are good by default as soon as I put a single many2many
    element in

    If table elements within many2many do not require any
    mapping specific attributes you might consider (if it is
    feasable) shorter syntax:
    <many2many tablea="ddddd" tableb="fffff" linktable="dfff"/>

     
  • Jens Langager Ellegaard

    Logged In: YES
    user_id=640391

    Hi roytana

    I think that instead of making the shorter mapping syntax you
    suggest, as in <many2many tablea="ddddd" tableb="fffff"
    linktable="dfff"/> , it would be better to make middlegen
    capable of handling the different 'singular' and 'plural' names
    for each many-to-many relations.

    If, for example, you have several other beans relating to a
    a 'people' bean, it is usefull to be able to refer to it as
    an 'employees' relation in one bean, as 'customers' in the
    secont etc.

    You might even require two relations from the same bean
    (home- and work phonenumbers, as an example), which is
    impossible if they cannot be named independently.

    It is obviously possible to provide this information in the
    present xml syntax, and I therefore suggest that fixing the
    bug is better than changing the relation syntax

    with regards

    Jens Ellegaard

     

Log in to post a comment.