cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Menard <>
Subject Enum best practices
Date Wed, 16 Jan 2008 15:43:32 GMT
Hi all,

I'm looking at a problem that enums look like a good fit for, but I've never
bothered with Cayenne's enum support.  So, I'm looking for some help on best

What I have is an "orders" table that I would like to store an "eval_status"
value to indicate whether the order is as an evaluation order and at what
stage of the eval it is.

Normally, I decompose everything and would have an "eval_status" table with
various values and set up an FK constraint on an "eval_status_id" column on
the "orders" table.  I don't expect these values to change, but if they do,
I'd like to be able to do a simple UPDATE statement on the one row.

In my code, however, I think it would be really nice to be able to use
expressions such as: if (EvalStatus.CONVERTED == order.getEvalStatus()).  It
seems that this would be much nicer than using a Cayenne DO for the

Despite all of this, I don't want to be binding the data model too tightly
to Java.  In the past we've used Python to access the DB, so I'd like to
support that as well as I can.

The best way I've come up with is if the enum maps its values to the PKs of
the entries in "eval_status" table.  I think this would achieve what I'd
like, with the downside that referential integrity may be compromised if I
update one but not the other.

Is this largely what others are doing?  Or, do you just use VARCHAR columns
and not worry about the normalization of the DB?


View raw message