UML Relationships

In regards to implementation of UML Relationships using Java, how are Aggregation and Dependency relationships typically implemented. I have Association and Generalization but am missing the other two.
Association - in Java, implemented as member variables in participating classes
Generalization - in Java, implemented using inheritance in source code (using extends keyword)
Aggregation/Composition - ? member variables also ?
Dependency - ?

So, Aggregation and Composition are special types of Associations. Put simply yes, though you will often find that people use associations during the early part of the analysis then resovlved this to either Aggregation or Composition as the class diagram design emerges from the domain model.
I describe aggregation as a dynamic association and composition as a static association.
So I would describe a Car as a composition which includes an Engine, without an Engine it is not really a Car. Composition is implicitly a bi-directionally realationship.
class Car {
Engine engine = New  Engine( this ) ;
class Engine {
Car car = null ;
public Engine(Car car) {
this.car = car;
}I could describe a Car and it's Driver as aggregation, a car is still a car without a driver and the lifetime of an instance of a car and the driver are not linked (well not usually :). A car has many drivers linked to it at various times during its lifetime.
class Car {
Driver driver;
public setDriver( Driver driver) {
this.driver = driver;
driver.drive( this ) ;
class Driver {
Car car;
public drive(Car car) {
this.car = car;
They too are implemented via class variables. They are more properly described as object references.
These may be Associative Classes, between the two Classes. In this example a Hashtable.
class Car {
Hashtable passengers;
public setPassenger( Passenger passenger) {
this.passengers.add( passenger ) ;
And those special rules you mention are
contingent upon how the developer writes the
application. Or in another way, it is the
responsibility of the developer to enfore the rules of
Association and Composition. There is nothing in the
Java 2 language that governs this behavior.True, mapping the association types from UML notation to code is the programmers job, and the exact implementation may vary with language semantics.. Though the OMG are defining the MDA to define the relationship bewteen UML model and implementation code.

Similar Messages

  • UML: From ER to UML to JAVA : many-to-many relationship implementation.

    Hi All,
    Basically, I just want to know if we have point 1 (ER), then is point 2 (UML) and point 3 (JAVA) correct? 1M Thanks.
    1. ER-wise, we have a many-to-many relationships between 2 tables A and B. Its implementation is:
    Table_A
    ID PK
    Table_B
    ID PK
    Table_AB
    ID FK REFERENCED TO TABLE_A
    ID FK REFERENCED TO TABLE_B
    DateCreated (a third column)
    2. UML-wise, we would have 2 classes Table_A, Table_B and an association class Table_AB. Is this correct? OR is there any other possibility depending on the nature of these classes Table_A, Table_B?
    3. Java-wise, we would have 3 below classes. Is this correct?
    OR is there any other possibility depending on the nature of these classes Table_A, Table_B?
    public class Table_A
         private int ID;
    public class Table_B
         private int ID;
    public class Table_AB
         private DateTime DateCreated;
         private Table_A a;
         private Table_B b;

    Hi MOD,
    1. Actually, the original question:
    Table_A<---many-to-many--->Table_B
    can be break down to
    Table_A<---1-to-many--->Table_AB and Table_AB<---many-to-1--->Table_B
    where Table_AB is an association class with an attribute.
    2. As for the Implementation, I have a reviewed version based upon point 1. for the point 3 of original post.
    import java.util.*;
    public class Table_A
         private int ID;
         List abList = new ArrayList();  // This is Table_A<---1-to-many--->Table_AB
         public Table_A(int ID)
              this.ID=ID;
         public void addTable_AB(Table_AB ab)
              abList.add(ab);
              ab.setTable_A(this);
         //...other methods
    public class Table_B
         private int ID;
         List abList = new ArrayList();  // This is Table_B<---1-to-many--->Table_AB
         public Table_B(int ID)
              this.ID=ID;
         public void addTable_AB(Table_AB ab)
              abList.add(ab);
              ab.setTable_B(this);
         //...other methods     
    public class Table_AB
         private Date DateCreated;     
         private Table_A a;     // This is Table_AB<---many-to-1--->Table_A
         private Table_B b;     // This is Table_AB<---many-to-1--->Table_B
         public Table_AB(Date DateCreated)
              this.DateCreated=DateCreated;
         public void setTable_A(Table_A a)
              this.a= a;
         public void setTable_B(Table_B b)
              this.b= b;
         //...other methods     
    }

  • UML from entity relationships

    Anyone know of any tools that generate UML from entity relationships?
    Thanks...

    Hi Shay,
    I have a third party application which has been coded extensively in JSPs (whew !!! talk about design). I am having a tough time trying to get the flow of the application from one JSP to another. And NO, the third party vendor does not have extensive documentation.
    May be I posed my question incorrectly. I probably am not particularly looking for UML but any tool that can reverse engineer the JSPs and give a pictorial representation of how these different JSPs are talking to each other or any other information.
    Do you know of any tool that can provide any such information ?
    Thanks,
    Pratul

  • NullPointerException at EJB-Relationship

    Hi:
    I'm trying to create a relationship between to CMP 2.0 entites using JDeveloper.
    It's a unidirectional One-to-Many relation between Car-producer and Car-typs.
    The car-type-bean has the producer number as a foreign key.
    I have generated the EJB'S with UML class diagramm.
    There is a Session Bean Interface with a local reference to the Entity Beans.
    If I test my Session Bean with the Oracle9i JDeveloper's Embedded Oracle9iAS J2EE Server there
    is a NullPointerException after deploying the Beans.
    Note: There is no error if I have only Session Bean with one Entity Bean without any relationships.
    the log-File is :
    D:\jdeveloper\jdk\bin\javaw.exe -ojvm -classpath D:\jdeveloper\j2ee\home\oc4j.jar -Xverify:none -Doracle.j2ee.dont.use.memory.archive=true
    com.evermind.server.OC4JServer -config D:\jdeveloper\jdev\system9.0.3.1.1107\oc4j-config\server.xml
    [Starting OC4J using the following ports: HTTP=8992, RMI=23892, JMS=9231.]
    [waiting for the server to complete its initialization...]
    Embedded OC4J startup time: 2464 ms.
    Copying default deployment descriptor from archive at D:\jdeveloper\jdev\mywork\Workspace1\Project1\classes/META-INF/orion-ejb-jar.xml
    to deployment directory D:\jdeveloper\jdev\system9.0.3.1.1107\oc4j-config\application-deployments\current-workspace-app\classes...
    Auto-deploying file:/D:/jdeveloper/jdev/mywork/Workspace1/Project1/classes/ (No previous deployment found)... java.lang.NullPointerException
         void com.evermind.server.ejb.compilation.CMPObjectCompilation.processContainerManagedField(com.evermind.server.ejb.deployment.ContainerManagedField, com.evermind.util.ByteString, boolean)
              CMPObjectCompilation.java:314
         void com.evermind.server.ejb.compilation.CMPObjectCompilation.processFields()
              CMPObjectCompilation.java:235
         void com.evermind.server.ejb.compilation.PersistenceManagerCompilation.compile()
              PersistenceManagerCompilation.java:59
         void com.evermind.server.ejb.compilation.EntityBeanCompilation.compile()
              EntityBeanCompilation.java:332
         void com.evermind.server.ejb.compilation.Compilation.compile()
              Compilation.java:288
         void com.evermind.server.ejb.EJBContainer.postInit(com.evermind.server.ejb.EJBContainerConfig, com.evermind.server.administration.ApplicationInstallation)
              EJBContainer.java:551
         void com.evermind.server.Application.postInit(com.evermind.server.ApplicationConfig, com.evermind.server.administration.ApplicationInstallation)
              Application.java:431
         void com.evermind.server.Application.setConfig(com.evermind.server.ApplicationConfig, com.evermind.server.administration.ApplicationInstallation)
              Application.java:136
         void com.evermind.server.ApplicationServer.addApplication(com.evermind.server.ApplicationConfig, com.evermind.server.Application, com.evermind.server.administration.ApplicationInstallation)
              ApplicationServer.java:1635
         com.evermind.server.Application com.evermind.server.ApplicationServer.getApplication(java.lang.String, com.evermind.util.ErrorHandler)
              ApplicationServer.java:2130
         void com.evermind.server.XMLApplicationServerConfig.initHttp(com.evermind.server.ApplicationServer)
              XMLApplicationServerConfig.java:1550
         void com.evermind.server.ApplicationServerLauncher.run()
              ApplicationServerLauncher.java:97
         void java.lang.Thread.run()
              Thread.java:484
    Please help with any idea.
    Thanks.

    Uta-
    It looks like you're running JDev 9.0.3.1. If it's not too much trouble, can you try this again with 9.0.3.2? There have been a number of codegen fixes since 9.0.3.1, so it would be best to rule them out first.
    If that doesn't fix things, or if that's not convenient, can you include the details of your car-producer and car-types schema objects? This will give me some more info to go on.
    Thanks,
    Jon

  • Practical use of UML diagramming tool....

    Hi ,
    the use of UML diagramming tool is to present the system to end user (use cases) ... like the Entity Relationship Diagram in the Oracle Designer....
    However , i 'd like to ask if the product of this tool can be used as a base to produce something else afterwards in the whole system...
    I mean that in Oacle Designer , when the analyst designs the ER Diagram and saves it to the repository... this can be used to automatically generate the tables... in the repository also and then to the database...!!!!!
    Is there analogous using UML diagramming tool....?????
    Many thanks,
    Simon

    The UML class diagram can generate Java classes and ADF Business Components.
    The Database modeler in JDeveloper can generate the database objects.
    Also when you are designing the page flow diagram you are actually building the JSF or Struts flows.
    The hands-on-lab that you can find on the right side of this page:
    http://www.oracle.com/technology/products/jdev/collateral/4gl/formsdesignerj2ee.html
    Shows off some of the model to code capabilities of JDeveloper:

  • UML diagrams using Jdeveloper 9.0.3

    I would like to get some help from people who have used Jdeveloper 9.0.3 for creating UML diagrams.
    scenario
    I have 2 packages namely com.pack.bo and com.pack.ejb created using Jdev.
    I have business objects represented in UML inside bo package and have SB's inside ejb package.
    Now how would i show the relationships from ejb's to bo's diagramatically ?
    Is there any way to show the above mentioned ?
    Thanks

    Hi,
    You could use the Dependency relationship to show the connection on a diagram. Also you could use Notes and Note Attachements to further annotate any relationship.
    Regards,
    Gerard Davison

  • UML to XML? How??

    Hi,
    I need to build an XML representation of an UML model (a couple of classes and relationships between them). I know that I must use an XMI standard representation, but my problem is another one:
    I know yet rules to generate an XMI-Schema (the specialized version of XSD schemas). I don't want to generate any schema, but a static rapresentation of classes and relationships through the XML elements like:
    <uml:model>,
    <uml:ownedElement>
    <uml:associationEnd>
    ....and so on
    I know that my xml doc should be something like:
    <?xml version='1.0' encoding='UTF-8'?>
    <!-- <!DOCTYPE XMI SYSTEM "uml14xmi12.dtd"> -->
    <XMI xmi.version='1.2' timestamp=<> xmlns:UML='omg.org/UML/1.4'>
      <XMI.header>
      </XMI.header>
      <XMI.content>
        <UML:Model ...>
        ... (the body of the document)
        </UML:Model>
      </XMI.content>
    </XMI>but... where I can find a complete list (and their usage) of all XML elements in the UML namespace?
    I have spent many hours on the OMG site, but without results. I know that the UML metamodel is described in terms of MOF, and I know that XMI defines how serialize MOF objects to XML... my problem is that I cannot find any document describing how to do this clearly...
    Somebody can help me?

    HOW can we make an activity diagram executable? how can we make a complete activity diagram such that it can be directly converted to source code? can anyone help me??

  • UML Association cardinality in Visio 2013

    Is there a way to define cardinality (1:1, 1:N, N:M,...) of associations in UML class diagrams in Visio 2013?
    Thanks for help.

    Hi,
    Use relationship to create the associations in UML diagrams.
    Then double click the relationship, enter the cardinality.
    Jaynet Zhang
    TechNet Community Support

  • UML notation in Class diagram

    Hello,
    I'd like to model a realationship between, for instance, Customer and
    Profile entities in my Class diagram. And I'd like to include class
    attributes to communicate better my design. I intend to implement
    both entities as Entity EJB. Which of the following options is
    correct for presenting a relationship between Customer and Profile in
    UML Class diagram:
    1) via Customer.profile and Profile.customer
    | Customer | | Profile |
    |id:long |---------|id:long |
    |profile:Profile|1 1|customer:Customer|
    --------------- |firstName:String |
    |lastName:String |
    |DOB:Date |
    |address:String |
    2) or via Customer.profile_id and Profile.customer_id
    | Customer | | Profile |
    |id:long |---------|id:long |
    |profile_id:long|1 1|customer_id:long |
    --------------- |firstName:String |
    |lastName:String |
    |DOB:Date |
    |address:String |
    In my database I would implement the relationship using id:long
    fields. But with UML diagram presentation I'm not sure because I've
    seen different appearences.
    Appreciate your help.

    [UML] however fails miserably with complex class
    diagrams...Of course I have seen huge class diagrams that where really terrible, because people mixed stuff that doesn't belong together. But I never noticed, that UML itself would be the problem. Do you have an example that couldn't conveied apropriate using UML ... and if possible a better way to get the idea across?
    regards
    Spieler

  • BPA: Unable to inlcude existing UML Class assocs in other diagram instances

    Hello,
    I have created some UML Class diagrams in Oracle Business Process Architect 11gR1 (490292) (SR 2010_07). When I create a new UML Class diagram I am able to drag-and-drop existing UML classes to the new diagram, but when I try to include some existing binary associations (that exist between the included classes) they are not included. I try to inlcude the associations as follows:
    1) Create a new UML Class diagram;
    2) Find some UML classes (that have an existing association between them) in the Designer Exprorer tree and drag-and-drop them in the diagram;
    3) Select one of these UML classes in the diagram (so the "Properties" panel fills with the details of the selected class);
    4) Go to the "Relationships" tab of the "Properties" panel and find the relationship that represents the requested binary association;
    5) Select the relationship and click the button "Show".
    Unfortunately, nothing happens (i.e. the association does not show in the diagram). The above sequence works fine in other model types (with other object types, for example in IE diagrams) but it does not work in UML Class diagrams.
    Am I doing it in a wrong way? Is there any workarond if this is a bug?
    Dimitar

    This problem seems to be a bug. However, I found the following workaround:
    1) Locate the UML classes on the new diagram;
    2) Try to create a new binary association between them. The BPA tool will check if there is an existing association between these classes and it will open a dialog box to ask you whether to create a new association or to use an existing one;
    3) Select the necessary (existing) association in the dialog box instead of confirming creation of a new one and the selected association will appear on the diagram.
    Dimitar

  • UML in JDeveloper

    I have been using JDeveloper for only a couple of weeks, mainly for UML design, and my first impression is that this is not a very mature functionality in JDeveloper...
    I have some questions I hope someone can help me with:
    1. The navigation tree in Application Navigator does not reflect the physical location of the folders/uml files on the harddisk... This makes navigation very chaotic in large projects..
    Is there a way to configure the Navigator to show the files this way:
    |--Application sources
    |''''|-----myDomain
    |''''|''''''''''''''|----myUmlFile1
    |''''|''''''''''''''|----mySubDomain
    |''''|''''''''''''''|'''''' |---myUmlFile2
    instead of:
    |--Application sources
    |'''''|-----myDomain
    |'''''|'''''''''''''|----myUmlFile1
    |'''''|----myDomain.mySubDomain
    |'''''|'''''''''''''|----myUmlFile2
    2. I haven't found a way to create a Use Case description report in JDeveloper (A document where you can insert text (preferrably divided into chapters) along with ANY kind of diagram and also the html part of the Use Cases...
    We need a way to create such documents without having to use copy and paste, and I was hoping JDeveloper had a way of creating such a document... Has anyone found a good solution for this?
    I was actually thinking of "integrating" OpenOffice Writer with JDeveloper, but since I also have used OpenOffice for only a couple of weeks, I have not yet learned all the tricks and features...
    For example, I had problems inserting (linking) a JDeveloper Use Case file (.xhtml_usc) into a OpenOffice Writer section... I could only insert it as xml, not as html...
    Hints would be very much appreciated...
    Another challenge is of course the JDeveloper UML diagrams...
    Is there a way to configure a diagram to automatically be published as a PNG file at a specified path every time you edit and save the diagram file? (then I could insert the PNG file as a link in OpenOffice, and be sure that OpenOffice always displays the latest version of the PNG file...)
    3. Refactoring UML files.... I surely hope that moving UML files is on the roadmap for JDeveloper? It is crucial that we are able to move a file from one domain to another...
    4. Why can't I add a component from another project to a diagram, when they belong to the same application?? I would like to divide my application into multiple projects representing the different domains of the application... And of course, add components from different projects to the same diagram to describe their relationships....
    thanks in advance for any help
    Message was edited by:
    user506305
    Message was edited by:
    user506305

    Hi,
    Answer 1:
    To get the Navigator to look like this you need to alter the 'Flat Level' to 1 by decreasing the 'Spinner Box' on the Application Navigator Toolbar.
    Answer 2:
    If you select the Project node and then select 'Run | JavaDoc <ProjectName>' this will generate a JavaDoc style HTML report with links on the diagram image which will take you throught to the create Use Case and Actor etc. It is probably not quite what you want but is at least in HTML to allow you to do what you want.
    No you can't configure JDev to publish the diagram everytime the diagram is saved.
    Answer 3:
    What issues are you having refactoring UML elements. You should be able to refactor all elements apart from the diagrams and packages.
    Answer 4:
    You can share models between different Projects but you need to go into the Project Properties and then select 'Project Content | Modelers' and then 'Add' the second Project's Model Path to this Project.
    Regards,
    Lisa
    JDev UML QA

  • DATABASE UML REPRESENTATION

    Hi,
    I have a database and want to use UML Notations to make a EER Diagram of it.
    Which tool is easy to use. I have already used microfost visio(gives an headache while using different arrows)

    >
    I'm trying to write a UML class diagram to
    demonstrate the relationship of some classes.
    Now I have the following construct:
    class A{ ... }
    class C{ ... }
    class B {
    the returned collection contains C's
    public Collection getCofA(A){ ... }
    There is insufficient Java here to determine the UML class diagra, (beyond the three obvious class boxes). a Class diagram shows the static relationship between the classes. So the last line does not add anythng.
    so one can think of it as A having C's,If A is a collection of C's this would be represented by the composite line if there is a return ref from each C to the A, or by the association line is there is no return reference. Multiplicity (0..*|1..*|N) would be is shown at the side with the multiplicity. C.
    Composition
    C aC = new C(this) ;
    aA.addC( aC ) ;
    Association
    C aC = new C() ;
    aA.addC( aC ) ;
    but there is no A.getC() or A.Ccollection ... but one
    uses the class B to represent the connection between > A and C.This is represented by an associative class. There are at least three seperate ways to show this in common use.
    1) link the two classes with a straight line. Draw a broken/dotted line off this line to the connection class.
    2) as 1 , except a diamond is added at the junction between broken and full line.
    3)Add a box off the collection handler class, make the association from this to the contained classes.
    I tend to use the final method
    How would one represent this connection in an UML
    class diagram?This really depend on the conventions in use at the site/case tool. Just document your conventions.

  • UML modeling is unusable

    While other features of the product are of appropriate quality, the UML support however is pretty much unusable for any sort of serious modeling. Resize to content doesn't work - shapes remain too big (try on Use Cases); Extension Points, though possible to define in Use Cases still useless as there is no way to assign them later to extension relationships; Documentation sucks big time with its ignorance to font settings and horrible text auto-formatting, which is impossible to configure; Text changes in documentation do not mark model 'dirty' so that you have to play around with diagram elements first to make your changes saved; No alignment support whatsoever; No line styles (i.e. straight, square, etc); Actor names frequently do not fit into the shape box - have to resize - and it looks very ugly. This is just basic Use Case diagramming. Class Diagrams - I have just started - UML syntax is violated in method specifications - i.e. public void test(int arg) instead of +test(arg:int):void - even though I selected platform independent UML project. State diagrams - you can put as many initial states and history labels as you like everywhere.
    Amazing. Worst quality product I have ever seen coming out of Sun. The impression is that it has never been tested at all.

    Another update to your feedback on Netbeans 5.5 preview. I also submitted each of your 6 as request for enhancements except for item 6 as a bug. I don't quite understand what the issue is with item 5. Could you please give me more detail about what the result is and what you expect it to be. Thanks again for your good feedback.
    --Peter                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • JDeveloper and UML

    Hi,
    I'm new to JDeveloper and UML and I'm wondering if the following is possible or even makes sense.
    Is it possible to link or "drill down" from a Use Case Diagram into a Class Diagram? I like the way I can publish a Use Case Diagram to HTML and it would be nice to start at this high level and then click down into the specific details of a Class Diagram.
    If I'm being too naive in my understanding of the relationship between these different UML levels, please let me know. Otherwise, if it is possible to link Use Case Diagrams w/ Class Diagrams, I would appreciate someone pointing me to a link.
    Thanks,
    Alan

    Hi Guus,
    What I was thinking of was something like the following:
    On my Use Case diagram, I have the following. An actor symbol (named User) and two Use Case symbols. The first Use Case Symbol is called "Creates Tax Record" and the second is called "Applies Tax to Vendor".
    What I would like to then to, is define a link on the "Creates Tax Record" use case that would drill down to a "Tax Record" Class Diagram. That diagram would then have the classes necessary to define a tax record.
    So then when I publish the Use Case and Class Diagrams, I could click on the "Creates Tax Record" use case and read the scenario and other information. I would also be able to click on the link to see what the class diagram looked like for that particular use case.
    So it sounds like I would need this "semantic locking" to be available somewhere on the Use Case information page. Am misunderstanding something about UML diagrams? Should there be a clear separation between the Use Case diagram and the Class diagram(s)?
    Thanks.
    Alan

  • UML model specifications?

    Hi,
    I want to build an XML representation of an UML model (a couple of classes and relationships between them). I know that I must use XMI, but my problem is another one:
    where I can find a specification doc concerning all the XML element that I must put inside the XMI declarations?
    (i.e. <uml:model>, <uml:ownedElement>, <uml:associationEnd>, and so on).
    I cannot find an exact description of all elements in the UML namespace that I must use.
    Somebody can help me?
    (I have spent many hours on the OMG site, but without results)

    of course, if somebody knows something about java librariers doing that work.... maybe he/she can help me.
    IBM at alphaworks develops something similar (many years ago) to produce XMI schemas from the scratch.
    Maybe something similar is exiting to produce an uml-xml representation of java objects.

Maybe you are looking for

  • Performance & Auto-write XMP

    I've noticed over the past week that people have been seeing subpar performance with auto-write XMP turned on while running Lightroom. I think this warrants a more detailed response from the team. Most people using auto-write will experience a minor

  • This is different: iTunes freezes my PC completely!

    Hello! I've searched the forums- I think my problem is unique. Basically, the iTunes installer completely hangs my PC. I need to do a hard reset every time. I've followed all the steps on Apple's troubleshooting guide to make sure EVERY trace of all

  • Using functions in default-field in wizzards

    Hi there, I tried to build a table in the database section of the portal with the primary key being a 'number'. Into the default-field I put the statement: SELECT <owner>.<sequence>.NEXTVAL FROM DUAL (the sequence I had defined before). This statemen

  • How can I know wich plug-in im missing?

    How can I know wich plugin im missing, it says that ¨this patch is not for you¨ Photoshop CC

  • My iPod wont come up onto iTunes....

    i just bought the iPod video today, and i love it, but the werid thing is i did everything i was supposed to do and it came up once and downloaded all of my songs onto it, but a few minutes ago i bought a video from iTunes and I'm trying to get it to