Ternary associations by R4R Team

As we are understanding with name of the topic Ternary association mapping that shows there is the three possible approaches to mapping a ternary association. One approach is use to a map with an association as its index.

Example of the Ternary association mapping:

public class Computer {
   int id;
   @OneToMany // unidirectional
   Map<Computer, Contract> contracts;

// or

<map name="contracts">
    <key column="employer_id" not-null="true"/>
    <map-key-many-to-many column="computer_id" class="Computer"/>
    <one-to-many class="Contract"/>

In the ternary association we found the second approach is to remodel the assocation as a entity class. We need to remember this because this is very common approach. we can use as a final alternative is to use composite elements which will be dicussed.

Leave a Comment:
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!