How to Create Associations in ADF

    0
    18
    Spread the love
    • 1
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
      1
      Share

    Alumni Association Association:-In today’s scenario most of the applications are based on relational database table structure.In my previous post https://www.techtravelhub.com/2012/04/how-to-create-entity-object-in.html
    I have told how to create Entity Object. If you look at very closely an EO is based on a single table.Now think about the scenario where there are two tables. Table one and table two and they are connected via foreign key relationship. So Entity Object one and Entity Object two must be connected via some link. This link is called Association.
    If the foreign key relationship is there , JDeveloper can create the relationship automatically. This relationship is called Association.So in other words , an association is a relationship between source and destination Entity Objects.
    Rules for Creating Association:
    1. For two connecting EOs say Employee and department the Naming convention will be employeeDepartmentAssoc i.e the table1table2Assoc
    2. Follow the camel case structure.
    3.Suffix Assoc is written to clearly understand the association.
    Case-1. If you have the  database ready the association is done by JDeveloper itself
    Case-2: if you do not have the direct association between themselves  follow the below written steps.
    Step-1: Click on File->New

    image

    Step 2: Select ADF Business Component from Business Tier from left pane.Select Association from right pane.click on OK.
    image 
    Step-3: if the database is not connected we might get a database connection prompt. Connect to the correct database and click on next.Provide Name of the association.Click on Next.
    image
    Step-4: Here we will be getting two Entity Objects. Select the source and destination Entity Object to create an association.
    image
    The other thing we need to take care is Cardinality.The different cardinalities imageareā€¦

    1. One to many
    2. many to one
    3. many to many

    During runtime programmatically application can determine for how many rows of the first table can access how many rows of the second table. 

    Step-5: Expand the EOs to establish a connection between themselves. When done the below section will activate


    image 
    Source and Destination Attribute: Below of the settings , there is another attribute list called source and destination attribute. It will clearly tell you association setting with the degree of Cardinality.
    Click on Next.
    Step-6: This page talks about more details about Accessors. The option of exposing accessors in the optional Java class that backs an entity object.
    image
    These assessors will give freedom to traverse between themselves programmatically
    Step-7: On the same page the last point is Composition Association . There are two types of associations..
    Reference The association references a destination entity object
    Contains The destination entity can be thought of as a logical subpart of the source
    image
    Enable that by clicking on the on/off switch.
    Click on Next
    Step-8: If we need to change query and add some more options , this is the page to fine tune and add query clause.
    image
    Click on Next.
    Step-9: This is the summary page of what the association we have made.
    image
    Click finish to create association successfully.
    Any point of time we can go back and change the wizard(code).
    Step-10. Double click or expand your folder for the association.
    image
    This is how we can create an association through ADF via JDeveloper.
    Photo credit : http://kingsway.dnn.appros.net

    Don't miss out!
    Subscribe To Newsletter

    Receive top technical news, lesson ideas, travel tips and more!

    Invalid email address
    Give it a try. You can unsubscribe at any time.

    Spread the love
    • 1
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
      1
      Share

    LEAVE A REPLY

    Please enter your comment!
    Please enter your name here