Re: How To Check Attribute's Width Programmatically?
Re: How To Check Attribute's Width Programmatically?
- Subject: Re: How To Check Attribute's Width Programmatically?
- From: Pierre Frisch <email@hidden>
- Date: Thu, 5 Feb 2004 14:47:27 -0800
Just one warning the attribute width in most database is the space in
bytes reserved for the varchar (In Oracle in particular) this has
nothing to do with the length of the String in Java especially if you
use UTF-8 storage. Most modern databases do not really use that value
anyway so why bother and give it a large number. Handcrafting that
value does not give you any performance advantage.
Pierre
--
Pierre Frisch
sPearWay Ltd.
sPearCat Web Catalogs, the flexibility of custom design, the price of a
package.
http://www.spearcat.com/
On Feb 5, 2004, at 14:22, Anjo Krank wrote:
>
> Am 05.02.2004 um 23:07 schrieb email@hidden:
>
>> I realize you can set and get attributes of an entity or table
>> programmatically (using either takeValueForKey or valueForKey())
>
> Not quite: you get the attribute value of an enterprise object. The
> "attribute" itself is an object describing what can be contained in
> the value.
>
>> I would however like to retrieve the maximum possible width of the
>> attribute in my program. I ask this because of so : I have an
>> attribute first_name in my table Subscribers. Its width attribut is
>> 150 varchar2().
>>
>> Now when subscribers are entering the first_name field through the
>> web interface I would like to do some length check (what if the
>> subscriber enters a name longer than 150 characters?) (please bear
>> with me this is just an example albiet a bad one)
>
> You should name your attribute in java convention, ie. "firstName",
> not "first_name". first_name should be the name of the column in the
> database.
>
>> In my validation mathod I would like to check if the string entered
>> is greater than the set width of the field of the table (whatever it
>> may be). I can put in a preset 150 characters but that is no fun
>> (because if you change the character width later on you will have to
>> go through the code and change all instance of 150 character width).
>>
>> Is it possible to retrieve the width of an attribute in the program ?
> Sth like:
> EOEnterpriseObject eo; // assume this is given
> int width = EOUtilities.entityNamed(eo.editingContext(),
> eo.entityName()).attributeNamed("foo").width();
>
> Cheers, Anjo
>
> _______________________________________________
> WebObjects-dev mailing list
> email@hidden
> http://www.omnigroup.com/mailman/listinfo/webobjects-dev
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.