Book a Demo

Author Topic: Many to N associations  (Read 3024 times)

M.Lay

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Many to N associations
« on: February 04, 2010, 03:04:51 am »
I am trying the trial copy of Enterprise Architect.   It has reverse engineered  my Java code. The only issue I am finding is that while it can reverse engineer 1 to 1 assocations, it does not seem to reverse many to 1 associations.  For example, if I have two classes A and B, if I have an attribute in A which is 'B myB = null ;, EA will create a line on the diagram.  However, if the attribute is 'List<B> listOfB = new ArrayList<B> ;', EA does not create a line on the diagram to represent the assocation.  Is there some setting I am missing ?  Thanks.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Many to N associations
« Reply #1 on: February 04, 2010, 09:01:37 am »
EA can model the associations you are describing through use of collection classes (http://www.sparxsystems.com/EAUserGuide/index.html?settingcollectionclasses.htm)  These set how relationships with multiplicity greater than one are generated and can be specified for each language or all associations to individual classes.  For associations where the multiplicity is one, you can only set this by setting the Member Type on the association.

EA currently only creates associations and dependency relationships from code where it finds that a type used in one class directly matches the name of another class.  It currently does not look at the types used as template/generic arguments or attempt to distinguish between when the template class itself should be the target of an association, or if it is acting as a container.

We plan on addressing these limitations and adding the capability of reverse engineering an association or dependency to the class used in a containing template.  However, at this stage the details of this or a release schedule are unavailable.

pinus

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Many to N associations
« Reply #2 on: February 11, 2010, 02:22:27 am »
Does it work with version 7.0?
And I wonder which form I should use?
Is Set enough or should I use java.lang.Set?
Which one works for forms?

pinus

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Many to N associations
« Reply #3 on: February 12, 2010, 10:07:12 pm »
I tried with the latest trial 7.5 but it doesn't work.
Importing the appended classes creates a diagram with
C -> A and B

but it should generate:
C -> A and B->A

EA loses the connection between  A and B   :(

Code: [Select]
package test;

public class A
{
}
Code: [Select]
package test;

import java.util.Set;

public class B
{
    public Set<A> getSet()
    {
        return null;
    }
}
Code: [Select]
package test;

public class C
{
    public A getA()
    {
        return null;
    }
}

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Many to N associations
« Reply #4 on: February 13, 2010, 04:17:39 am »
Pinus,

That would be the expected result given that EA doesn't account for generics as Simon pointed out.
Have you tried in v 8.0?

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Many to N associations
« Reply #5 on: February 15, 2010, 09:06:48 am »
Hasn't changed in 8.