On 15.03.2010 13:46, Nilima R wrote:
Can someone tell me how to use create enums with Dynamic values in Guvnor.
For example I need enum which does not contain static value like A,B,C rather these A,B,C values come from database.

Hi,

if the set of allowable enum literals/values is altogether dynamic, this probably cannot be achieved without dynamic bytecode generation (i. e. generate the enum class at runtime). I'm not aware that Drools supports this, you'd probably have to code this on your own.

If your database contains a known set of enum values (like "A", "B", "C"), you could create an enum with these values and perform string to enum mapping using <YourEnumClass>.valueOf(nameOfLiteral).

If both approaches don't fit your need, you can still stick with ordinary strings.

Most of the times I worked with "enums in a database", there actually was a finite set of allowable values - sometimes it's hard to find out all the values in this set, but should be doable. Otherwise an enum seems kind of a mis-fit for the problem at hand, because an enum (short for "enumeration") actually means the set of values can be enumerated.

Ansgar