Re: How To Use A Type Safe Enum As A Custom Value In EOF (was Re: (EOM) entity logic)
Re: How To Use A Type Safe Enum As A Custom Value In EOF (was Re: (EOM) entity logic)
- Subject: Re: How To Use A Type Safe Enum As A Custom Value In EOF (was Re: (EOM) entity logic)
- From: Arturo Perez <email@hidden>
- Date: Mon, 01 Aug 2005 10:06:03 -0400
Hi John,
That's what I was afraid of. What started me thinking is that in my
RDBMS of choice a CHAR is 4-5 bytes (due to DB overhead and encoding
paranoia). So I tried using a byte array, which works fine, but is also
4-5 bytes in length. I was just trying to get that down to 2 bytes. I
don't know what the overhead of smallints are, anyway, so maybe it's all
the same. I really would like to use plain integer values, though,
instead of these binary data types.
In sum, I guess your recommendation would be that I use a CHAR, and do a
Integer.parseInt() on it?
John Bruce wrote:
Hi Arturo,
What I do is store an Integer as a string in the database and then in
my objectWithArchiveData it converts the string into an Integer and
then returns the correct object. This means that the size of the field
in the databsae has to be at most 3 chars, which is fairly small. I
have a super class which does all of this for each enum.
Not sure if that helps but if you want I can send / post my super
implementation.
Cheers,
John
On 8/1/05, Arturo PĂ©rez <email@hidden> wrote:
Hi all,
I was looking at this Type Safe Enum pattern. Implemented it, works
fine but I have a space-efficiency question.
Essentially, what I want is a enum in the C sense where I can specify
the values; e.g. RED=1, BLUE=2, etc. But using the code below my
choice of data storage is either a String or NSData. But for space
efficiency I'ld like to use database smallints.
Is there anyway to get objectWithArchiveData to take anything other
than strings and NSData? More specifically, is there any way to get it
to take integer values?
TIA,
-arturo
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden