We use an Oracle 8i database with our old WebObjects apps, and we often have
INTEGER column to represent a boolean value, for example, IS_MANAGER in the
EMPLOYEE table. In WebObjects we modeled those columns with NSNumber
attributes, which was tedious because we had to convert the numbers to boolean
values every time we used them.
In Cayenne I've been able to model such columns with attributes of type
java.lang.Boolean without changing the database. It looks promising because
this works as expected:
Boolean isManager = employee.getIsManager(); // works
But I ran into a little surprise doing a query. If I do this:
Expression qual = ExpressionFactory.matchExp("isManager", new Boolean
(true));
I get this in the log:
SELECT t0.EmployeeCode, t0.IsManager, ... FROM EMPLOYEE t0
WHERE t0.IsManager = ? [bind: 'true']
[QueryLogger] *** error.
java.lang.ClassCastException
at oracle.jdbc.driver.OraclePreparedStatement.setObject
(OraclePreparedStatement.java:2018)
at oracle.jdbc.driver.OraclePreparedStatement.setObject
(OraclePreparedStatement.java:2099)
at org.objectstyle.cayenne.access.types.AbstractType.setJdbcObject
(AbstractType.java:78)
at org.objectstyle.cayenne.dba.JdbcAdapter.bindParameter
(JdbcAdapter.java:544)
If I change the query to say new Integer(1) it works, so I have a
work-around, but it's odd to use Integer in one place and Boolean in another.
Should I form the query some other way? Maybe this is an Oracle driver
problem?
Thanks.
This archive was generated by hypermail 2.0.0 : Sat May 29 2004 - 22:01:37 EDT