You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Robert Zeigler <ro...@puregumption.com> on 2007/07/24 22:16:23 UTC
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
Re: 2.x, custom (enum) types, mysql, and in expressions?
Posted by Robert Zeigler <ro...@puregumption.com>.
PS: This is on os x 10.4, java version 1.5.0_07-164.
Robert
On Jul 24, 2007, at 7/243:16 PM , Robert Zeigler wrote:
> 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
>