• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: EOModelPrototype CastClass Exception
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EOModelPrototype CastClass Exception


  • Subject: Re: EOModelPrototype CastClass Exception
  • From: James Cicenia <email@hidden>
  • Date: Sat, 18 Dec 2004 13:21:04 -0600

Hmm..

I figured out that it has to do with TINYINT in mySQL. I think the solution is to change it to INT.
mySQL seems to return something that I can't figure out how to cast when it is a TINYINT




On Dec 18, 2004, at 12:57 PM, MacFirst wrote:

on 12/18/04 9:49 AM, Kieran Kelleher <email@hidden> went on and
on saying, in part:


On Dec 18, 2004, at 11:44 AM, James Cicenia wrote:
I have an eogenerator template that creates code for Booleans:

public Boolean canAdminSite() {
return new
Boolean(((Integer)storedValueForKey("canAdminSite")).intValue()==1);
}

And my eomodel states:
ValueClass = Number
ExternalType = INT
ValueType = i
ValueClass = NSNumber

Why would the above code cause a class cast exception?

Sometimes breaking up a complex statement into simpler ones can help
figure out what's going wrong. Try something like this:

[rewrite of routine, snipped

A good technique but, if you're interested in why the original went wrong,
try breaking IT into smaller chunks, without rewriting it. Vis:


public Boolean canAdminsite() {
Integer storedValue = (Integer) storedValueForKey ("canAdminSite");
int iStoredValue = storedValue.intValue();
boolean boo = (iStoredValue == 1);
Boolean result = new Boolean (boo);
return (result);
}


Then, one at a time, substitute longer things back in for your intermediate
values. Although... Looking at it, I don't see anything wrong with yours.
The only thing I can see that you're missing is check if the stored value is
null. I typically use something like:


    public  boolean canAdminSite()
    {
        return (canAdminSiteBool() != null
        &&      canAdminSiteBool().intValue() == 1);
    }

(canAdminSiteBool() is the stored value in the model.)

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________ 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
References: 
 >Re: EOModelPrototype CastClass Exception (From: MacFirst <email@hidden>)

  • Prev by Date: Re: EOModelPrototype CastClass Exception
  • Next by Date: locking problem
  • Previous by thread: Re: EOModelPrototype CastClass Exception
  • Next by thread: locking problem
  • Index(es):
    • Date
    • Thread