Author Topic: Generating get/set for associations in java  (Read 1139 times)

Chris Sparrow

  • Guest
Generating get/set for associations in java
« on: August 23, 2002, 02:37:45 pm »
It appears that EA should generate a get method and set method for any associations that I have for a class, according to the dialog box for generation options->attribute/operations.  There is a checkbox that says "Generate Get/Set methods for associated attributes".  I have it checked, but when I generate my java, I don't get the methods, only the association attributes.

Is there something else I should be doing?

sparks

  • EA Administrator
  • EA User
  • *****
  • Posts: 591
  • Karma: +3/-0
    • View Profile
Re: Generating get/set for associations in java
« Reply #1 on: August 27, 2002, 06:08:44 am »
Hello,

Your message didn't mention if you have flagged each attribute as a property.  Once you do this to an attribute you will be shown the 'Create Property Implementation" screen, where you can define your preferences for the getter and setter.  Hope this helps.

Paul Mathers

Chris Sparrow

  • Guest
Re: Generating get/set for associations in java
« Reply #2 on: November 01, 2002, 09:33:28 am »
I understand that if you add an attribute to a class the flag it as a property it will create the getter and setter for that attribute.  What I am having trouble with is when you associate one class with another class.  A getter and setter are not being created.  

For Example, I have a class Branch  it is associated with a class of Bank with a multiplicity of 1.  I Select the Associate tool and draw a line between the two classes.  I type "owningBank" in the target role (no "owningBank" attribute has been defined for Branch).  When I generate the code for a Branch, I get an attribute owningBank of class Bank, but not getter or setter.

With tools I have used in the past associating the classes automatically creates the attribute and the getter and setter.

Sandro Gava

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Generating get/set for associations in java
« Reply #3 on: November 06, 2002, 04:06:01 am »
Hello,

If you  have an 1-to-1 association, there is a way to solve your problem: I find that if I add an attribute (and set the property flag) with the same name of the association target role, EA will generate the right code.
This doesn't seem to work if the association is of type 1-to-many.  :(

Sandro Gava