2.x, custom (enum) types, mysql, and in expressions?

From: Robert Zeigler (robert..uregumption.com)
Date: Tue Jul 24 2007 - 16:16:23 EDT

  • Next message: Robert Zeigler: "Re: 2.x, custom (enum) types, mysql, and in expressions?"

    Hi all,

    Ran into a strange error recently.
    I have a table "Enrollments" with a column "grade" which maps to an
    enum.
    I was trying to find all enrollments associated with one or more
    particular grades. Basic query looks something like:

    SelectQuery q = new SelectQuery(Enrollment.class);
    q.setQualifier(ExpressionFactory.inExp
    (Enrollment.GRADE_PROPERTY,Arrays.asList(Grade.FIRST,Grade.SECOND)));

    I have a setup where all of my database-facing tests run against an
    in-memory hsql database. The above worked just fine there. However,
    when I ran the code via the application, which is backed by a mysql
    server (5.0.27), it returned no results. Everything looked fine when
    I turned on query logging... the queries in the test and in the app
    were identical. So I turned to the mysql query logs and found this
    (truncated to the relevant portions for clarity):

    SELECT t0.grade, t0.id, t0.studentid FROM enrollments t0, students t1
    WHERE t0.studentid = t1.dbid AND (t0.grade IN ('??\0~r\0!
    org.edkey.attendance.domain.Grade\0\0\0\0\0\0\0\0\0\0xr
    \0java.lang.Enum\0\0\0\0\0\0\0\0\0\0xpt\0FIRST', '??\0~r\0!
    org.edkey.attendance.domain.Grade\0\0\0\0\0\0\0\0\0\0xr
    \0java.lang.Enum\0\0\0\0\0\0\0\0\0\0xpt\0SECOND')))

    This is using version 5.0.4 of the mysql-connector driver.

    I changed my test for this particular piece of code to connect to the
    mysql-backed db with the same results as running "live".

    Any thoughts? Am I doing something wrong? Seems odd that it works
    with hsqldb, but not mysql?

    Robert



    This archive was generated by hypermail 2.0.0 : Tue Jul 24 2007 - 16:16:55 EDT