Class > ERD: column naming / composite key

Hi Community,
I am a student from germany and currently evaluating VP. I am interested in modelling classes in UML in order to generate the java and database code with the persistence layer.

Now I am running into some problems:

1. Association: Automated naming of the table columns:
UML-Model > Java works very well. The attribute name of the classes is defined by the role name of the association. But when I generate the ERD, the name of the column (the foreign key) is the exact name of the primary key the column refers to. My problem is, that if one class has 2 associations to one other class (e.g. departure, destination), VP will make primarykeyname and tablename+primarykeyname out of it. This isn’t very meaningful. I don’t want to fix the ERD by myself, because then I have to do it whenever I change the UML model.

2. Defining PK in UML
I am not sure how I can say VP which attribute should become the primary key. Only when I create a new class, start the wizard (/Tools/Object-Orientied-Mapping(ORM)/Wizards…) then I can assign the attributes. But only once! I wasn’t able to find where I can change the PK afterwards.

3. Association class / composite key

There is a n-n association between 2 classes in my model (2x 0…n) and there is an association class attached with no further attributes. Unfortunately the genereted ERD has no primary key for the association class and of course, the db generation fails. The 2 foreign keys have to be the composite key. After fixing the ERD and syncing with the class diagramm, the code generation works, but I can not find any difference in the uml model. Maybe this is the same issue as point 2.

Thanks in advance for helping me. Maybe you, the VP crew, should add an up-to-date and more complex sample. The UMLNotations.vpp project is supposedly an older version and I miss a <> scenario with the hibernate layer.

:slight_smile:

HI duff_beer,

Thank you for your post. Let me try to answer your questions one by one.

  1. we allow user to customize the way how foreign key will appear.
    i. Select Tools > Options from the main menu
    ii. Open the “Diagramming” page
    iii. Open the “ERD & ORM” tab
    iv. Edit the “Foreign Key Pattern”

Could you try and let me know if it solves your problem?

  1. When you synchronize from Class Diagram to ERD the first time, you can select the attribute to relate to the primary key column. If you want to change the mapping, you can create an ORM Diagram, visualize the mapping, and remap the column with attribute.
    http://files3.visual-paradigm.com/200707/Jick/change-mapping.html

  2. I will discuss with our engineers first.

Best regards,
Jick

Thank you Jick for your answer,

[quote=Jick]HI duff_beer,

Thank you for your post. Let me try to answer your questions one by one.

  1. we allow user to customize the way how foreign key will appear.
    i. Select Tools > Options from the main menu
    ii. Open the “Diagramming” page
    iii. Open the “ERD & ORM” tab
    iv. Edit the “Foreign Key Pattern”
    [/quote]But there are only limited possibilies:
    {fk_name}
    {reference_table_name}
    {reference_column_name}
    I am missing the role name. Unfortunately the “sync to ERD” function does not include changes of the pattern - so you have to delete the ERD first.

[quote=Jick]2. When you synchronize from Class Diagram to ERD the first time, you can select the attribute to relate to the primary key column. If you want to change the mapping, you can create an ORM Diagram, visualize the mapping, and remap the column with attribute.
http://files3.visual-paradigm.com/200707/Jick/change-mapping.html
[/quote]Thank you, this helps :slight_smile:

Some more things:
Class Diagramm: attribute type char[x] (x stands for length) is always mapped to a char[1] in the ERD

It would be nice when you synchronize from Class Diagram to ERD the first time, the wizard could also allow associations (future foreign key relations) and not only class attributes for the foreign key. And it would also be nice, if more than one PK could be selected.

I like the single source principle. This model should contain all necessary information in order not to adjust the derived models, like the ERD.

Hope I can contribute to improve the tool a littel bit :slight_smile: I am still not fully certain if VP is the right tool, but I really like the generated hibernate persistence layer. This saves a lot of stupid work :slight_smile:

Hi duff,

Thanks for your valuable suggestions. I will discuss with our engineers one by one, and then reply you.

Best regards,
Jick

Hi duff,

Sorry that we cannot support synchronizing the length of char array as it does not conform to Hibernate, which will cause problem in ORM.

Will keep you informed on other issues.

Best regards,
Jick

Hi duff,

With regards to the 3rd point you mentioned in the original message, there was a bug concerning synchronization between class and ER model which cause the code generation didn’t work. Now, it is fixed. Please download the patch at:
http://files3.visual-paradigm.com/200707/Patch/sp2_20070704r/VP_Suite_Windows_3_0_sp2_20070704r.exe

Please run it and install by overwriting the current installation. Please feel free to let me know if there are any questions.

Best regards,
Jick

Hi duff,

We have written a plugin to serve your first request of naming foreign key. Please find the plugin attached. To use the plugin:

  1. Unzip it
  2. Create a “plugins” folder under %VP Suite installation director%
  3. Put the extracted folder to %VP Suite installation director%/plugins so that you will have the following folder structure
    %VP Suite installation director%\plugins\com.vp.plugin.sample.fknaming\src…
  4. Start VP-UML
  5. Run the plugin by pressing the icon in the toolbar. Read the attached image for detail.

This will update the name of foreign keys appear in the ACTIVE diagram.

Hope you like this. Feel free to let me know if there are any questions.

Best regards,
Jick
com.vp.plugin.sample.fknaming.zip
plugin.png