Book a Demo

Author Topic: Java code generation-EA doesn't use collections(?)  (Read 3445 times)

lukasz314

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Java code generation-EA doesn't use collections(?)
« on: June 22, 2005, 03:36:06 pm »
Hello,

I've just installed EA 5 and I'm currently trying it out. I must say that it looks very promising to me - very robust and certainly more user-friendly than some of its well known competitors! :)

Unfortunately, when trying Java code generation feature, I've noticed that I can't force EA to use collections when generating code for modelled 1..n relationship.

My model contains two classes: A and B. There is an association from A and B and B's cardinality is set to '1..'. The problem is, no matter how I set the relationship's properties (I've tried quite many combinations..), generated class A.java always has a field of type B - instead of java.util.Vector I've set in the configuration.

Does anyone has any idea what I might be doing wrong? Please help :)

Regards,
Lukasz

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Java code generation-EA doesn't use collection
« Reply #1 on: June 22, 2005, 05:46:21 pm »
You need to tell EA what collection classes to use.

You can find all of the information by searching the EA help file for "Setting Collection Classes" or at the following url.

http://sparxsystems.com.au/EAUserGuide/index.html?settingcollectionclasses.htm

Simon

lukasz314

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Java code generation-EA doesn't use collection
« Reply #2 on: June 23, 2005, 03:13:11 am »
Hi Simon,

Thanks for the reply. Unfortunately, my problem ocurred despite that under:
Local Options->Generation-> Java Specificatios-> Collection Classes

I've had all three fields set to 'java.util.Vector'.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Java code generation-EA doesn't use collection
« Reply #3 on: June 23, 2005, 03:53:52 pm »
Sorry, I completely missed the bit where you said you had set it up.

It is possible to set this up on a class level. (Class Properties, detail tab and the collection classes button there)

I wonder if you have actually set that.  If you open up that dialog, I half expect to see '#TYPE#' in each of them.  If they need to be blank for the language level collection classes to be used.

Alternatively, try creating a brand new class, an association with 1.. cardinality to it and code generate.  This does work for me.

I hope that is the problem and that this helps.

Simon

lukasz314

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Java code generation-EA doesn't use collection
« Reply #4 on: June 24, 2005, 01:31:34 pm »
After trying some more combinations I've finally found the one that works...

Now I've got a problem with setting the aggregation's direction. After setting it to 'Bi-directional', EA still generates appropriate field only in one of the aggregation's classes.

I wonder if there's some kind of detailed documentation that would describe rules of uml -> code transformation.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Java code generation-EA doesn't use collection
« Reply #5 on: June 24, 2005, 03:37:18 pm »
Quote
After trying some more combinations I've finally found the one that works...

Now I've got a problem with setting the aggregation's direction. After setting it to 'Bi-directional', EA still generates appropriate field only in one of the aggregation's classes.

I wonder if there's some kind of detailed documentation that would describe rules of uml -> code transformation.
Hi Lukasz,

the following link
http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=UMLPRO;action=display;num=1119458061contains the results of some experimentation by Christopher_Wells.

Have you provided role names at both ends of the aggregation?  That may affect the result.

HTH,

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Java code generation-EA doesn't use collection
« Reply #6 on: June 26, 2005, 03:29:22 pm »
If you're using Bi-directional links, make sure you have set the multiplicity for both roles.

Simon