Mod4j: Modeling for Java using Domain Specific Languages
  1. Mod4j: Modeling for Java using Domain Specific Languages
  2. MODFORJ-192

The role name of the many end of an association cannot be the same as the classname.

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.0
    • Fix Version/s: x.x
    • Labels:
      None
    • Number of attachments :
      0

      Description

      The role name of the many end of a one-to-many association cannot be the (case-insensitively) same as the name of the class at the many end. This is because code is generated to iterate through the elements of the Set corresponding to the association that uses the but with a lowercase first letter as the name of variable for the element in each loop iteration. That name conflicts with the name of the association that is also derived from the classname with a lowercase first letter.

        Activity

        Hide
        Eric Jan Malotaux added a comment -

        A simple work-around is to always use for the role name the plural form of the noun used as class name. That way they are (almost) always different.

        Show
        Eric Jan Malotaux added a comment - A simple work-around is to always use for the role name the plural form of the noun used as class name. That way they are (almost) always different.
        Hide
        Jos Warmer added a comment -

        I would like to change the generated loop variable name into something that does not conflict easily, maybe start (or end) it with an underscore.

        Show
        Jos Warmer added a comment - I would like to change the generated loop variable name into something that does not conflict easily, maybe start (or end) it with an underscore.
        Hide
        Eric Jan Malotaux added a comment -

        Yes, and then adding a constraint on role names that they cannot start (or end) with an underscore.

        Show
        Eric Jan Malotaux added a comment - Yes, and then adding a constraint on role names that they cannot start (or end) with an underscore.
        Hide
        Eric Jan Malotaux added a comment -

        The solution is even simpler: just qualify the field for the association (with the name of the role) with "this.".

        Show
        Eric Jan Malotaux added a comment - The solution is even simpler: just qualify the field for the association (with the name of the role) with "this.".
        Hide
        Jos Warmer added a comment -

        Checked ok

        Show
        Jos Warmer added a comment - Checked ok

          People

          • Assignee:
            Eric Jan Malotaux
            Reporter:
            Eric Jan Malotaux
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: