Question

I'm creating a class diagram in Visual Paradigm with "ORM Persistable" types "A" and "B", where A holds a ordered list of B. I'm trying to configure the many-to-many association in the class diagram, where the association is only navigable from A->B and the order of the B instances in the list is given by the order they are added to the list at runtime. When Visual Paradigm creates the hibernate mapping files this should result in an association table "a2b" in the ERD with the fields "a_id", "b_id", "order_idx", and a hibernate mapping for the type "A" defining a list property "bs" where the list-index is the "order_idx" of the association table, like in:

<class name="A" table="a"> 
  <id name="id" column="id" /> 
  <list name="bs" table="a2b"> 
  <key column="a_id" /> 
  <list-index column="order_idx" base="1" /> 
    <many-to-many class="B" column="b_id" /> 
  </list> 
</class> 

but I can't get it working. Visual Paradigm creates index columns in the association table both for type A and B and a list for A instances in the B type (although the association is not navigable in this direction). If I try to create an association type for A->B with an "order" property, this also doesn't work out (which is quite clear, but I tried any lead ...). Also when I define the ORM->Collection Type->List, I get this error message: null (A->B) The ordered relationship does not specify the ordered column.

How can I define such an association in Visual Paradigm in the class diagram?

Was it helpful?

Solution

I've got a feedback from Visual Paradigm solving this issue: To define an ordered collection between to java types "A" and "B" resulting in a list collection in the hibernate mapping one has to go through the following steps:

  • Define the ORM Persistable types in the class diagram enter image description here

  • Create the ERD diagram for those types, e.g. by the Visual Paradigm move "right-click combined with Mouse Drag". enter image description here

  • Add the "order column" to the association from table "A" to table "A_B". Right click the association and choose "Open Specification". enter image description here
  • Then click the check-box "Ordered" and choose the column with the order index. In this example no such column yet exists, so I choose "Create Column..." enter image description here
  • In this example, the column name "Index" and datatype int(10) have to be configured (because the column didn't exist before) enter image description here
  • This results in the ERD diagram as depicted below: enter image description here
  • Then also configure the association from table "B" to table "A_B" to be ordered and use the very same index column. enter image description here
  • Now the ordered many-to-many uni-directional association is fully configured and Visual Paradigm is able to create the hibernate mapping as cited in the question above. Feine Sache :-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top