And the exceptionstack:
invalid enum equal expression, cannot compare enum value of type
[de.encom.fourpro.plannings.data.PlanningRelationType} with a non enum value
of type [java.lang.Object].
at
oracle.toplink.essentials.exceptions.EJBQLException.invalidEnumEqualExpressi
on(EJBQLException.java:484)
at
oracle.toplink.essentials.internal.parsing.EqualsNode.validate(EqualsNode.ja
va:70)
at
oracle.toplink.essentials.internal.parsing.OrNode.validate(OrNode.java:77)
at
oracle.toplink.essentials.internal.parsing.Node.validate(Node.java:118)
at
oracle.toplink.essentials.internal.parsing.LogicalOperatorNode.validate(Logi
calOperatorNode.java:63)
at
oracle.toplink.essentials.internal.parsing.WhereNode.validate(WhereNode.java
:58)
at
oracle.toplink.essentials.internal.parsing.ParseTree.validate(ParseTree.java
:235)
at
oracle.toplink.essentials.internal.parsing.ParseTree.validate(ParseTree.java
:211)
at
oracle.toplink.essentials.internal.parsing.ParseTree.validate(ParseTree.java
:201)
at
oracle.toplink.essentials.internal.parsing.EJBQLParseTree.populateReadQueryI
nternal(EJBQLParseTree.java:134)
at
oracle.toplink.essentials.internal.parsing.EJBQLParseTree.populateQuery(EJBQ
LParseTree.java:108)
at
oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLData
baseQuery(EJBQueryImpl.java:219)
at
oracle.toplink.essentials.queryframework.EJBQLPlaceHolderQuery.processEjbQLQ
uery(EJBQLPlaceHolderQuery.java:111)
at
oracle.toplink.essentials.internal.sessions.AbstractSession.processEJBQLQuer
ies(AbstractSession.java:2059)
at
oracle.toplink.essentials.internal.sessions.AbstractSession.processEJBQLQuer
ies(AbstractSession.java:2046)
at
oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.postConnectD
atasource(DatabaseSessionImpl.java:724)
at
oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.loginAndDete
ctDatasource(DatabaseSessionImpl.java:604)
at
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.login(Entity
ManagerFactoryProvider.java:280)
at
oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(En
tityManagerSetupImpl.java:229)
at
oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.ge
tServerSession(EntityManagerFactoryImpl.java:93)
at
oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.cr
eateEntityManagerImpl(EntityManagerFactoryImpl.java:126)
at
oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createE
ntityManager(EntityManagerFactoryImpl.java:99)
at
com.sun.enterprise.util.EntityManagerWrapper._getDelegate(EntityManagerWrapp
er.java:326)
at
com.sun.enterprise.util.EntityManagerWrapper.createQuery(EntityManagerWrappe
r.java:660)
_____
Von: Christian Kerwer [mailto:Christian.Kerwer_at_t-online.de]
Gesendet: Montag, 28. Januar 2008 16:35
An: persistence_at_glassfish.dev.java.net
Betreff: Bug Comparing Enum with Bindingparameter
Here ist the NamedQuery:
@NamedQuery(
name =
"PlanningObjectLink-ChildrenWithRelationTypeAndStructureId",
query = "select lnk"
+ " from PlanningObjectLink lnk, PlanningObject po"
+ " join lnk.planningClassLink pcl"
+ " join lnk.reference lref"
+ " join lnk.parent lp"
+ " join pcl.structureList pcs"
+ " where lp.id = :planningObjectId"
+ " and pcs.id = :planningClassStructureId"
+ " and lref = po and " +
PlanningAuthClauses.AUTH_PLAN_OBJ_CLAUSES
+ " and (:planningRelationType is null or
pcl.planningRelationType = :planningRelationType)"
+ " order by po.name"
This is the joined Entity Field (in Entity PlanningClassLink)
@Enumerated(value=EnumType.STRING)
@Column( name = "RELATIONTYPE" )
private PlanningRelationType planningRelationType;
And this is the execution:
Query v_Query = getEntityManager().createNamedQuery(
"PlanningObjectLink-ParentsWithRelationTypeInStructureId" );
v_Query.setParameter( "planningObjectId", p_PlanningObject.getId() );
v_Query.setParameter( "planningClassStructureId",
p_PlanningClassStructure.getId() );
if (p_FollowOnlyPrimaryLinks)
{
v_Query.setParameter( "planningRelationType",
PlanningRelationType.PRIMARY.toString() );
}
else
{
v_Query.setParameter( "planningRelationType", null );
}
// Hier muß die Rechteprüfung ausgeschaltet sein!
v_Query.setParameter( "isAdmin", true );
v_Query.setParameter( "funcKey", null );
v_Query.setParameter( "userId", null );
List<PlanningObjectLink> v_LinksToParenst;
try
{
v_LinksToParenst = (List<PlanningObjectLink>)
v_Query.getResultList();
}
catch( IllegalStateException e )
{
throw new DAOException( this, e );
}
catch( IllegalArgumentException e )
{
throw new DAOException( this, e );
}
_____
Von: Gordon Yorke [mailto:gordon.yorke_at_oracle.com]
Gesendet: Montag, 28. Januar 2008 16:18
An: persistence_at_glassfish.dev.java.net
Betreff: RE: Bug Comparing Enum with Bindingparameter
Can you provide the section of code that is setting the parameter and
executing the query. Can you send a bit more of the stack trace?
--Gordon
-----Original Message-----
From: Christian Kerwer [mailto:Christian.Kerwer_at_t-online.de]
Sent: Monday, January 28, 2008 9:50 AM
To: persistence_at_glassfish.dev.java.net
Subject: Bug Comparing Enum with Bindingparameter
Hello,
I’m experiencing a problem with NamedQueries.
In den following example in a NamedQuery an enum-field is to be compared
with an binding-parameter.
There’s no reason why this is not allowed, since it is possible to bind enum
parameter with ‚query.setParameter()’.
Toplink quits this issue with the following reason:
invalid enum equal expression, cannot compare enum value of type
[MyEnumType] with a non enum value of type [java.lang.Object]
Anyone an idea?