Re: Postgresql + booleans = error
Re: Postgresql + booleans = error
- Subject: Re: Postgresql + booleans = error
- From: shaun <email@hidden>
- Date: Sat, 18 Feb 2006 12:46:06 +1030
Hi,
On Sat, 2006-02-18 at 12:53 +1100, Lachlan Deck wrote:
> Hi there,
>
> further to the other's suggestions...
>
> On 16/02/2006, at 2:40 AM, Randall Perry wrote:
>
> > I used eomodeler to generate the model and EO classes from a
> > Postgresql db.
> > I'm having a problem using the boolean data type. If I reference a
> > boolean
> > field 'rec.campsiteFri()' like so:
> >
> > if (rec.campsiteFri()) {
> > return true;
> > }
> >
> > I get a compiler error 'incompatible types'.
>
> Of course you do. For these kinds of Java-based errors you need to
> ask yourself:
> The return type of campsiteFri() is:
> a) a 'boolean'
> b) a 'Boolean'
> c) a 'Number'
> d) a primitive other than 'boolean'
> e) some other Object
>
> You answer will have to be anything other than 'a' because in Java
> (as opposed to C) 'if' statements must take a 'boolean' primitive
> only (or an expression that returns a boolean primitive). Not an int
> or even an Object of type Boolean.
>
I just thought I'd point out that if your using Java 5.0 that you can do
the following:
Boolean b = new Boolean(true);
if (b){
// its true
}else{
// its false
}
Yay autoboxing!
regards
-shaun
_______________________________________________
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