Re: Bit and Boolean

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Dec 08 2003 - 19:47:12 EST

  • Next message: Andrus Adamchik: "Re: Bit and Boolean"

    On Dec 8, 2003, at 1:58 PM, Jim Menard wrote:

    > I have a database column that I defined as BIT, because it looked like
    > that was the right thing to do for boolean values. The corresponding
    > object's field is declared as Boolean, of course.
    >
    > When I try to run a query that uses the boolean field, I see the error
    >
    > Caused by: java.sql.SQLException: ERROR: Unable to identify an
    > operator '=' for types 'bit' and 'boolean'
    > You will have to retype this query using an explicit cast
    >
    > Here's the query:
    >
    > SelectQuery query =
    > new SelectQuery(Member.class,
    > ExpressionFactory.matchExp("username",
    > username));
    > query.andQualifier(ExpressionFactory.matchExp("password",
    > password));
    > query.andQualifier(ExpressionFactory.matchExp("active",
    > Boolean.TRUE));
    >
    > What have I done wrong: declare the database field as BIT (should it
    > be something else)? Use matchExp() improperly?

    Hi Jim,

    Your code looks correct.

    I just realized that we did not have test cases for the BIT values, so
    I created one and ran it on Oracle, MySQL and PostgreSQL. Everything
    worked fine on the first two, but PostgreSQL blew up with the error
    similar to what you describe. Looks like a PG JDBC driver doesn't
    support boolean to bit conversions. Even though this seems like a
    driver problem, I opened a bug:

    http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-55

      Will see how we can address that... It shouldn't be too hard, we've
    had similar problems with other drivers and other data types, so there
    is a standard solution.

    Andrus



    This archive was generated by hypermail 2.0.0 : Mon Dec 08 2003 - 19:47:18 EST