Simeon Johnston
2005-01-11 21:36:41 UTC
I'm using Postgresql 7.4.6 with it's supplied jdbc driver with the
Wonder project plugin.
My eomodel is using EOJDBCPrototypes for all field types.
Booleans are setup as suggested -
allowsNull = Y;
columnName = "";
externalType = bool;
name = boolean;
valueClassName = NSNumber;
valueType = c;
The classes were generated with eogenerator.
Everything I've found so far says that the above configuration should
work... and yet I keep getting ClassCastExceptions on the booleans.
So, I switched my prototype for booleans to a internal data type of
'String'.
No more exceptions...
And no wonder I was getting exceptions. The return value for booleans
is 't'. Which is fine for Postgresql, which apparently could return
any value from '1', 'y', 'TRUE', 'true', 't' for true (matching values
for false).
ermm... GREAT. just great.
SO...
This was built using FrontBase, which seems to return booleans for all
booleans.
To keep the code changes as minimal as possible, what would you suggest
to fix this boolean inconsistency?
Does the plugin handle this type of problem? Is the Driver supposed
to handle this?
Should I change the eogenerator created classes so all Boolean methods
check what the actual value is ('t', 'TRUE', 1 etc.) and return a
Numeric 1/0 (which is what EOModeler and eogenerator wants to do by
default anyway)? This would actually involve changing the eogenerator
templates as it is run every time the project is built in order to keep
all the classes consistent with the eomodel file.
I REALLY don't want to have to have every single Boolean (Number)
method changed in order to fix this inconsistency between FrontBase and
Postgresql. I'm really looking for something that could be sub-classed
or over ridden and just change the way these are handled at the lowest
level so that ALL booleans from the database (and from the app to the
database) are the same.
Any suggestions would be very helpful.
sim
Wonder project plugin.
My eomodel is using EOJDBCPrototypes for all field types.
Booleans are setup as suggested -
allowsNull = Y;
columnName = "";
externalType = bool;
name = boolean;
valueClassName = NSNumber;
valueType = c;
The classes were generated with eogenerator.
Everything I've found so far says that the above configuration should
work... and yet I keep getting ClassCastExceptions on the booleans.
So, I switched my prototype for booleans to a internal data type of
'String'.
No more exceptions...
And no wonder I was getting exceptions. The return value for booleans
is 't'. Which is fine for Postgresql, which apparently could return
any value from '1', 'y', 'TRUE', 'true', 't' for true (matching values
for false).
ermm... GREAT. just great.
SO...
This was built using FrontBase, which seems to return booleans for all
booleans.
To keep the code changes as minimal as possible, what would you suggest
to fix this boolean inconsistency?
Does the plugin handle this type of problem? Is the Driver supposed
to handle this?
Should I change the eogenerator created classes so all Boolean methods
check what the actual value is ('t', 'TRUE', 1 etc.) and return a
Numeric 1/0 (which is what EOModeler and eogenerator wants to do by
default anyway)? This would actually involve changing the eogenerator
templates as it is run every time the project is built in order to keep
all the classes consistent with the eomodel file.
I REALLY don't want to have to have every single Boolean (Number)
method changed in order to fix this inconsistency between FrontBase and
Postgresql. I'm really looking for something that could be sub-classed
or over ridden and just change the way these are handled at the lowest
level so that ALL booleans from the database (and from the app to the
database) are the same.
Any suggestions would be very helpful.
sim