cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Huang <>
Subject RE: Do we allow ENUM database types?
Date Thu, 01 Aug 2013 20:43:06 GMT

We actually have plenty of places that uses enums.  I think you're specifically talking about
saving the ordinal values of an enum into the database.  You can do that easily by putting
this annotation on the field.


The DB layer will take care of saving the ordinal value and retrieving and matching that value
back to the enum.

With that said, I do want to point out that saving ordinal values have operational issues.
 The biggest is people forget what they are and have to keep referring back to documents/code
to figure out what it means.   The gain from saving a ordinal value vs the string value in
indexing is fairly minimal due to the range of values being fairly limited in most enum definitions.
 Therefore, my preference is to save the String value instead.

To do that you can use this annotation.

There's an example of it in with the Type enum.


> -----Original Message-----
> From: Wido den Hollander []
> Sent: Thursday, August 1, 2013 11:12 AM
> To:
> Subject: Do we allow ENUM database types?
> Hi,
> I'm working on a disk cache setting for per disk offering which allows users to
> set it to:
> - none (current behaviour and default)
> - writeback
> - writethrough
> I've done some work in the disk-cache branch [0] where I created a new
> column called "cache_mode" in the disk_offering table.
> It's currently a varchar(32), but only 3 strings are allowed in the column, as
> listed above.
> We don't use enums anywhere in the database, so I was wondering if there
> is a good reason for that?
> Otherwise I think using a enum here would be a good use-case.
> Wido
> [0]:
> https://git-wip-
> cache

View raw message