Postgresql Boolean problems...

Simeon Johnston <[email protected]> Tue, 11 Jan 2005 13:36:43 -0600
Newsgroups gmane.comp.web.webobjects.eof
Message-ID <[email protected]>

Begin forwarded message:

> From: Simeon Johnston <[email protected]>
> Date: January 10, 2005 3:06:41 PM CST
> To: [email protected]
> Subject: Postgresql Boolean problems...
>
> This might not be just a problem with postgresql.
>
> My problem...
> We have a project that has been running very well on FrontBase.  I'm 
> trying to get it to work with Postgresql as well (i.e. it needs to 
> work with BOTH).  I've compiled the jdbc driver from postgresql and 
> I'm also using the plugin from the Wonder project.
>
> I've setup everything in the EOModel file to use prototypes.
> I've setup all the prototypes for Postgresql.
> eogenerator was used to generate the class files.
>
> The problem I'm  having right now is with booleans.  I've seen many 
> posts about this problem, but not real solutions I can use.
> The prototype is setup as recommended -
>
>             allowsNull = Y;
>             columnName = "";
>             externalType = bool;
>             name = boolean;
>             valueClassName = NSNumber;
>             valueType = c;
>
> The method for accessing it -
>
>     public Number active() {
>         return (Number)storedValueForKey("active");
>     }
>
>     public void setActive(Number aValue) {
>         takeStoredValueForKey(aValue, "active");
>     }
>
> As far as I can tell everything is setup correctly, but as soon as I 
> try to write anything to the db I get a ClassCastException error.
>
> What exactly is the problem with Postgresql and booleans?
> I'd rather just use Integers for booleans (Postgresql seems allows 
> textual 'true'/'false' or 1/0), which is the way FrontBase seems to 
> work.
> I DON'T want to convert the existing code to use an Integer or varchar 
> to store true/false values (one of the suggested fixes).  I'd rather 
> just fix the actual problem than work around it...
> But first I need to figure out what the problem is since my current 
> setup seems to have worked for other people.
>
> sim