# Subtle code generation problem with association classes

**URL:** <https://forums.visual-paradigm.com/t/subtle-code-generation-problem-with-association-classes/9000>\
**Category:** General Questions/Discussions\
**Created:** [July 11, 2006, 1:42am UTC](https://forums.visual-paradigm.com/t/subtle-code-generation-problem-with-association-classes/9000 "2006-07-11T01:42:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean-Marie2](https://avatars.discourse-cdn.com/v2/letter/j/8e8cbc/32.png) [@Jean-Marie2](https://forums.visual-paradigm.com/u/Jean-Marie2)\
**Post date:** [July 11, 2006, 1:42am UTC](https://forums.visual-paradigm.com/t/subtle-code-generation-problem-with-association-classes/9000/1 "2006-07-11T01:42:58Z")

</div>

Hi,

I encountered a small problem with code generation for an association class:

I have a relationship between LibelleMultiLingue and Langue, naviguable from LibelleMultiLingue to Langue, with an association class. In LibelleMultiLingue, VP generates the following method:

```auto
	public Traduction getTraductionByLangue(Langue aLangue) {
		Traduction[] lTraductions = traductions.toArray();
		for(int i = 0; i < lTraductions.length; i++) {
			if(lTraductions[i].getLangue().equals(aLangue)) {
				return lTraductions[i];
			}
		}
		return null;
	}

```

This cannot work as is, since equals is not redefined in class Langue. This is of course trivial to solve like this:

```auto
    public boolean equals (Object o) {
        if (o == this)
            return true;
        if (o instanceof Langue)
            return (Langue)o.getBusinessKey () == this.getBusinessKey ();
        } else
            return false;
    }

```

but I think it should be automatically generated, wouldn’t it ? Of course, the user should be able to choose the business key.

For the same diagram, I’d like to be able to specify that the relationship is mapped to a Map, indexed by one of the existing fields of the target class of the association (“businessKey” in class “Langue” in my sample). Is this possible ? I didn’t find any way to do that. Choosing “Map” for the association in “ORM/Collection type” produces a Map indexed by an auto-generated field in the target class.

Anyway, SDE is a great, great product !

Thanks in advance for any remark,

JM

```auto

```

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [July 21, 2006, 4:47pm UTC](https://forums.visual-paradigm.com/t/subtle-code-generation-problem-with-association-classes/9000/2 "2006-07-21T16:47:46Z")

</div>

Hi Jean-Marie,

Sorry for my late reply. Actually I have passed your message on to our team before, but I forgot to post here. Anyway, I will keep you posted on any updated news about your request.

Best Regards,  
Jick

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [August 14, 2006, 1:40pm UTC](https://forums.visual-paradigm.com/t/subtle-code-generation-problem-with-association-classes/9000/3 "2006-08-14T13:40:28Z")

</div>

Hi Jean-Marie,

I just sent you a private message. Please let me know if you have received it.

Best Regards,  
Jick

---

<div class="post-metadata">

**Author:** ![Jean-Marie2](https://avatars.discourse-cdn.com/v2/letter/j/8e8cbc/32.png) [@Jean-Marie2](https://forums.visual-paradigm.com/u/Jean-Marie2)\
**Post date:** [August 24, 2006, 4:54pm UTC](https://forums.visual-paradigm.com/t/subtle-code-generation-problem-with-association-classes/9000/4 "2006-08-24T16:54:58Z")

</div>

Hi Jick,

[quote=Jick]Hi Jean-Marie,

I just sent you a private message. Please let me know if you have received it.  
[/quote]

I’m sorry, I have been on vacation and didn’t look at the forum: No I didn’t get your private message in my mailbox. Could you please try to repost it ? Thanks a lot for your help, and I am still 200% happy with Visual Paradigm.

Best regards,

Jean-marie

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [August 25, 2006, 9:56am UTC](https://forums.visual-paradigm.com/t/subtle-code-generation-problem-with-association-classes/9000/5 "2006-08-25T09:56:53Z")

</div>

Hi Jean-marie,

I just resent you my private message. Please check your mail box. Thank you.

Best regards,  
Jick
