Hi all,
This isn't a huge issue, I'm just wondering if I'm doing something wrong...
In the following query, I'm attempting to specify an enum literal value
(CourseRole.P) and it's throwing an exception. It works fine if I prefix the
enum with it's package name. It doesn't seem like I should have to do this
though. I'm wondering if specifying the fully qualified name of the enum is
required? As far as I know, I shouldn't have to include the enum in the list
of classes in persistence.xml. I've tried it with or without it in
persistence.xml and it doesn't seem to make a difference.
The other thing that I was wondering is if it's possible to map the string
values of the enum to something other than what it would be normally. e.g.
say I have an enum CourseRole.INSTRUCTOR, I want it to be stored as the
string "P" in the database. As far as I know, it's not possible to do this.
Normally, it wouldn't be an issue, but, the database I'm working with isn't
one that I've designed myself.
Feb 22, 2007 5:43:44 PM edu.uchicago.at.appointments.AppointmentsService
findCourses
FINEST: SELECT c FROM Course c JOIN c.courseMemberships cm WHERE
cm.user.userName = :userName AND cm.courseRole = CourseRole.P ORDER BY
c.name
------------- ---------------- ---------------
Testcase:
testFindCourses(edu.uchicago.at.appointments.AppointmentsServiceTest):
Caused an ERROR
An exception occured while creating a query in EntityManager
java.lang.IllegalArgumentException: An exception occured while creating a
query in EntityManager
at
oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:194)
at
edu.uchicago.at.appointments.AppointmentsService.findCourses(AppointmentsService.java:70)
at
edu.uchicago.at.appointments.AppointmentsServiceTest.testFindCourses(AppointmentsServiceTest.java:40)
Caused by: Exception [TOPLINK-8004] (Oracle TopLink Essentials - 9.1 (Build
b33)): oracle.toplink.essentials.exceptions.EJBQLException
Exception Description: Error compiling the query [SELECT c FROM Course c
JOIN c.courseMemberships cm WHERE cm.user.userName = :userName AND
cm.courseRole = CourseRole.P ORDER BY c.name], line 1, column 107: unknown
identification variable [CourseRole]. The FROM clause of the query does not
declare an identification variable [CourseRole].
at
oracle.toplink.essentials.exceptions.EJBQLException.aliasResolutionException(EJBQLException.java:194)
at
oracle.toplink.essentials.internal.parsing.DotNode.validate(DotNode.java:106)
at
oracle.toplink.essentials.internal.parsing.Node.validate(Node.java:103)
at
oracle.toplink.essentials.internal.parsing.BinaryOperatorNode.validate(BinaryOperatorNode.java:43)
at
oracle.toplink.essentials.internal.parsing.EqualsNode.validate(EqualsNode.java:50)
at
oracle.toplink.essentials.internal.parsing.Node.validate(Node.java:103)
at
oracle.toplink.essentials.internal.parsing.LogicalOperatorNode.validate(LogicalOperatorNode.java:48)
at
oracle.toplink.essentials.internal.parsing.WhereNode.validate(WhereNode.java:43)
at
oracle.toplink.essentials.internal.parsing.ParseTree.validate(ParseTree.java:226)
at
oracle.toplink.essentials.internal.parsing.ParseTree.validate(ParseTree.java:202)
at
oracle.toplink.essentials.internal.parsing.ParseTree.validate(ParseTree.java:192)
at
oracle.toplink.essentials.internal.parsing.EJBQLParseTree.populateReadQueryInternal(EJBQLParseTree.java:119)
at
oracle.toplink.essentials.internal.parsing.EJBQLParseTree.populateQuery(EJBQLParseTree.java:93)
at
oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:204)
at
oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:174)
at
oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:138)
at
oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:99)
at
oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:84)
at
oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl.<init>(EJBQueryImpl.java:71)
at
oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:189)
... 17 more
Jon