Home > Diagrams > Class Diagram

Association Class

In modeling an association, there are times when you need to include another class because it includes valuable information about the relationship.
For this you would use an association class that you tie to the primary association.
An association class is represented like a normal class. The difference is that the association line between the primary classes intersects a dotted line connected to the association class.

EclipseUML provides two kinds of association class:
  1. Java Association Class
  2. Metamodel Association Class (MDA)

1. Java Association Class

Figure below shows an association class for Student Enrollment example.
Note that Association Class is only working if using Metamodel Association menu.
For example let's create two Java Classes in your Class Diagram and add a metamodel association between them

Rename both Classes to Student and Course, add attributes & methods in the Student Class, and add a constraint on the age.

Create an association class using the top down menu.

Add a link from the association class to the selected association link (e.g.metamodel association).

The association class ends will be automatically created once the association class link is connected to the association.

2. Metamodel Association Class

Let use the XMI Editor to create all class diagram elements and not generate any java code.
Figure below shows an association class for the airline industry example.
Create a new Class in the metamodel by selecting the package > New Child > Package Element > Class

Rename the created class to Flight using the property view Name Field.

Create a new association class by selecting the package > New Child > Packaged Element > Association Class.

Drag and drop the metamodel classes from the XMI editor to the Class Diagram (e.g. No Java code will be created).

Add a property to your metamodel Class using the Class contextual menu > New > Property.
(Note that you can add the name of the property with no syntax control using the Property View).

Here is the created diagram and the metamodel view of the created class diagram.