How to use Enumerations with ORM persistable classes

Before using VP, we created our Entity classes manually. For some attributes we are using Enumeration values

Example:

@Column(name = “NATION_TYP”)
@Enumerated(EnumType.STRING)
private Nation _nationTyp;

where Nation is an enumeration type;

How can i implement this within a class diagram? When designing Nation as a class with stereotype <> and using the Type Nation as type of an attribute in some other class, code generation complains about

[10:35:03] [Error] foerderung: AttributeClass Antrag’s attribute (nation : Nation) must specify a supported type.

Hi Spilker,

Thanks for your post. It seems that you have raised the same question to our support team (Ticket ID: BLS-241525), and our members in Europe support team has response to it already. If I’m right, please check the mail sent from our Europe member. Thanks!

Best regards,
Lilian Wong

Hello,

I’m right now facing the same problem. Is there any progress or answer/tip you could share on this? Right now I cannot figure out how to gerneate orm code when using an enumeration type for an attribute on a ORM persistable class.

Thanks,
Eike

Hi Eike,

Thanks for your post. Please refer to the following link for generating ORM code for enumeration type:
http://oldresources.visual-paradigm.com/vpsuite2.3sp1/user_type.html

Hope this helps. If there is any further inquiry, please feel free to ask.

Best regards,
Lilian Wong

Hi Lilian,

thank you for your answer! The link you provided contains some interesting information, but apparently it does not help me out. The article shows how to include database specific types in my erd model. But my problem is, that I like to do OR-Mapping starting from a class diagram (ie. for hibernate) and I want to tell VP-UML to include user-defined type mappings (extending the hibernate class/interface UserType) to use for any enumeration attribute type.

I attached a sample screenshot of what I’m trying to do. If I try to generate ORM code from this example it does not work because of “Class MarketStatus’ attribute (ACTIVE) must specify a supported type.” But actually I have implemented a user defined type mapping that maps the enumeration to a varchar and would specify this in the hibernate xml mapping. I don’t know how to tell VPUML to use this mapping.

I’m not good at describing my problem, I hope you know what I mean :slight_smile:

Thanks and kind regards
Eike

orm_enum.jpg

Hi Eike,

We support defining User Type and Parameterized Type in the latest version (VP Suite 4.0). I have prepared some flash movies to show you how to do. Please watch below:

Modeling:
http://files4.visual-paradigm.com/res/orm/user-type/01-modeling.htm

Implementation:
http://files4.visual-paradigm.com/res/orm/user-type/02-coding.htm
(don’t worry about the speed, attached are the source files for you :slight_smile: )

Testing:
http://files4.visual-paradigm.com/res/orm/user-type/03-testing.htm

For details, please refer to this article:
http://resources.visual-paradigm.com/index.php/component/content/article/71-general/364-hib-user-type.html

Hope this helps. I hope that you can try it out, and let me know if you are pleased with it. If you have any opinion, feel free to let me know.

Best regards,
Jick
MarketStatusUserType.java
MarketStatus.java

Hi Jick,

Thank you very much for your answer! I really like watching those videos! And of course this feature is really great. Apparently my version of vp uml is that of suite 3.4. So I guess I cannot use this feature until I upgrade.

Another note: The code that is generated for the enumeration is not implemented with a java 5 enumeration class. It’s using “the old” way to code enumerations (which is probably that what’s going on under the hood of the enumeration class). But I would actually prefer to use java5 enumerations. Will this be possible?

Kind Regards,
Eike

Hi Eike,

Thank you for coming back. I have passed your request to our team for further feasible study. I will let you know when there is any news. Feel free to let me know if you need other helps. :slight_smile: :slight_smile:

Best regards,
Jick

Hi Eike,

I would like to let you know that we will support ORM Java 5 enumeration in next release (VP Suite 4.1), you will be able to get the ORM Java 5 enumeration code by <> + <> in VP Suite 4.1.

BTW, I left a private message for you, please have a check.

Best regards,
Lilian Wong

Thanks Lilian, this post help me to, but i need this specifically for postgresql (8.4…). Is it possible you please point out how to use Enumerations and User types in postgresql ?
I experience more than one problem. Firstly, the connection from vp-uml to my postgresql database won’t work. Well, the SDE for Eclipse work though. But i prefer using the vp-uml.
Thanks for helping!

[quote=LilianWong]Hi Eike,

Thanks for your post. Please refer to the following link for generating ORM code for enumeration type:
http://oldresources.visual-paradigm.com/vpsuite2.3sp1/user_type.html

Hope this helps. If there is any further inquiry, please feel free to ask.

Best regards,
Lilian Wong[/quote]

Hello,
I have the same problem, i need to generate enumerations from class diagram to ERD diagram, and eventually generate hibernate code but i am getting th following error [14:34:13] [Error] name: Attribute Class Color’s attribute (name : ColorName) must specify a supported type.
ColorName is the enumeration class.
none of the above urls are working.

Please reference to the article below about how to use custom type for hibernate code generation.