Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » The parameter name in the query's selection criteria does not match any parameter name defined in th
The parameter name in the query's selection criteria does not match any parameter name defined in th [message #657595] Thu, 03 March 2011 11:56 Go to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 807
Registered: July 2009
Senior Member
I'm getting this rather lenghty exception and can't make heads or tails of it.

It seems the exception is trying to tell me that I specified a parameter name, that is not present in the query.
So something like "... where a = :a" and then do a query.setParameter("b", ...).
But I never created that query. (Eclipselink 2.2.0).

Local Exception Stack:
Exception [EclipseLink-6094] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.QueryException
Exception Description: The parameter name [relationstandnr] in the query's selection criteria does not match any parameter name defined in the query.
Query: ReadAllQuery(name="iRelationstandToCatsWhereIAmRelationstand " referenceClass=RelationstandToCat sql="SELECT relationstand2catnr, dwhby, dwhmodified, relationstandcatnr, relationstandnr FROM rel
ationstand_to_cat WHERE (relationstandnr = ?)")
at org.eclipse.persistence.exceptions.QueryException.parameterN ameMismatch(QueryException.java:1050)
at org.eclipse.persistence.internal.expressions.ParameterExpres sion.getValue(ParameterExpression.java:246)
at org.eclipse.persistence.internal.databaseaccess.DatabaseCall .translate(DatabaseCall.java:951)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism.executeCall(DatasourceCallQueryMechanism.java:206)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism.executeCall(DatasourceCallQueryMechanism.java:193)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism.executeSelectCall(DatasourceCallQueryMechanism.jav a:264)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism.selectAllRows(DatasourceCallQueryMechanism.java:64 7)
at org.eclipse.persistence.internal.queries.ExpressionQueryMech anism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2 558)
at org.eclipse.persistence.internal.queries.ExpressionQueryMech anism.selectAllRows(ExpressionQueryMechanism.java:2517)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLe velReadQuery(ReadAllQuery.java:410)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute DatabaseQuery(ObjectLevelReadQuery.java:1080)
at org.eclipse.persistence.queries.DatabaseQuery.execute(Databa seQuery.java:808)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute (ObjectLevelReadQuery.java:1040)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAll Query.java:383)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute InUnitOfWork(ObjectLevelReadQuery.java:1126)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.int ernalExecuteQuery(UnitOfWorkImpl.java:2842)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1521)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1503)
at org.eclipse.persistence.internal.indirection.QueryBasedValue Holder.instantiate(QueryBasedValueHolder.java:98)
at org.eclipse.persistence.internal.indirection.QueryBasedValue Holder.instantiateForUnitOfWorkValueHolder(QueryBasedValueHo lder.java:113)
at org.eclipse.persistence.internal.indirection.UnitOfWorkValue Holder.instantiateImpl(UnitOfWorkValueHolder.java:156)
at org.eclipse.persistence.internal.indirection.UnitOfWorkValue Holder.instantiate(UnitOfWorkValueHolder.java:222)
at org.eclipse.persistence.internal.indirection.DatabaseValueHo lder.getValue(DatabaseValueHolder.java:88)
at org.eclipse.persistence.indirection.IndirectList.buildDelega te(IndirectList.java:237)
at org.eclipse.persistence.indirection.IndirectList.getDelegate (IndirectList.java:397)
at org.eclipse.persistence.indirection.IndirectList.size(Indire ctList.java:726)
at org.eclipse.persistence.internal.queries.CollectionContainer Policy.sizeFor(CollectionContainerPolicy.java:177)
at org.eclipse.persistence.mappings.CollectionMapping.mergeInto Object(CollectionMapping.java:1395)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.m ergeIntoObject(ObjectBuilder.java:3254)
at org.eclipse.persistence.internal.sessions.MergeManager.merge ChangesOfCloneIntoWorkingCopy(MergeManager.java:525)
at org.eclipse.persistence.internal.sessions.MergeManager.merge Changes(MergeManager.java:263)
at org.eclipse.persistence.mappings.CollectionMapping.mergeInto Object(CollectionMapping.java:1452)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.m ergeIntoObject(ObjectBuilder.java:3254)
at org.eclipse.persistence.internal.sessions.MergeManager.merge ChangesOfCloneIntoWorkingCopy(MergeManager.java:525)
at org.eclipse.persistence.internal.sessions.MergeManager.merge Changes(MergeManager.java:263)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mer geCloneWithReferences(UnitOfWorkImpl.java:3467)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUni tOfWork.mergeCloneWithReferences(RepeatableWriteUnitOfWork.j ava:363)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mer geCloneWithReferences(UnitOfWorkImpl.java:3427)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.merge Internal(EntityManagerImpl.java:452)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.merge (EntityManagerImpl.java:429)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at nl.knowledgeplaza.util.jpa.EntityManagerExtender.invoke(Enti tyManagerExtender.java:384)
at $Proxy4.merge(Unknown Source)
at org.tbee.swing.jpa.JpaObjectNavigatorModel$1.call(JpaObjectN avigatorModel.java:936)
at org.tbee.swing.jpa.JpaObjectNavigatorModel.doSave(JpaObjectN avigatorModel.java:964)
at org.tbee.swing.jpa.JpaObjectNavigatorModel.doSave(JpaObjectN avigatorModel.java:905)
at org.tbee.swing.jpa.JpaObjectNavigatorBar$3.actionPerformed(J paObjectNavigatorBar.java:171)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unk nown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)



This is the table definition of relationstand_to_cat:
Column name Type Nulls
relationstand2catnr integer yes
relationstandnr integer no
relationstandcatnr integer no
dwhmodified datetime year to second yes
dwhby integer yes
Re: The parameter name in the query's selection criteria does not match any parameter name defined i [message #657631 is a reply to message #657595] Thu, 03 March 2011 13:16 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 807
Registered: July 2009
Senior Member
This problem does not occur when using Eclipselink 2.0.2!
Re: The parameter name in the query's selection criteria does not match any parameter name defined i [message #657645 is a reply to message #657595] Thu, 03 March 2011 15:04 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The query is for the iRelationstandToCatsWhereIAmRelationstand relationship. Please include the mapping for this attribute.

It could be a case issue. Are you using a native SQL query to retrieve the object being merged?

Does this error occur every time you access this relationship, or only in a certain case?


James : Wiki : Book : Blog : Twitter
Re: The parameter name in the query's selection criteria does not match any parameter name defined i [message #657659 is a reply to message #657645] Thu, 03 March 2011 15:33 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 807
Registered: July 2009
Senior Member
No, I'm not doing anything here, it's the result of a multi-cascade on an object (Relation) being merged into an EM. (Look further up the stacktrace.)

@OneToMany(mappedBy = "iRelationstand", fetch = FetchType.LAZY, targetEntity = nl.reinders.bm.RelationstandToCat.class, cascade = {CascadeType.REFRESH,CascadeType.PERSIST,CascadeType.MERGE} )
volatile protected java.util.List<nl.reinders.bm.RelationstandToCat> iRelationstandToCatsWhereIAmRelationstand = new java.util.ArrayList<nl.reinders.bm.RelationstandToCat>();

It only occurs when this merge happens (when the users presses the save button, the screen works fine until then).

On 3-3-2011 16:04, James wrote:
> The query is for the iRelationstandToCatsWhereIAmRelationstand relationship. Please include the mapping for this attribute.
>
> It could be a case issue. Are you using a native SQL query to retrieve the object being merged?
>
> Does this error occur every time you access this relationship, or only in a certain case?
>
Re: The parameter name in the query's selection criteria does not match any parameter name defined i [message #658522 is a reply to message #657659] Tue, 08 March 2011 20:14 Go to previous messageGo to next message
Andrew Rustleund is currently offline Andrew Rustleund
Messages: 6
Registered: March 2011
Junior Member
I seem to be getting the same issue with Eclipselink 2.2.0. This is code that was working with version 2.1.1.

I have narrowed my issue down to the following situation:

I make a new instance of an entity "A" and merge it with the entity manager (this entity must have Collection properties on it).

I take this entity "A" after it is merged and set it as a property on a different entity "B" (a new instance of a different class). When I call merge for this new entity "B", I get the stack trace already posted here.

By experimentation I found that when I removed all of the Collection properties from "A" and only had simple properties, the issue did not occur. Also, if I simply set my new instance "A" on the new instance "B" and merge it all together, it's fine.

However, the issue will also occur if I retrieve an existing entity "A" from the entity manager, set it on a new instance "B", and then attempt to merge "B".
Re: The parameter name in the query's selection criteria does not match any parameter name defined i [message #658538 is a reply to message #658522] Tue, 08 March 2011 21:20 Go to previous messageGo to next message
Andrew Rustleund is currently offline Andrew Rustleund
Messages: 6
Registered: March 2011
Junior Member
I found another condition that when removed will resolve this issue.

I have selective caching turned on in my persistence unit:

<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>


When I remove this, my code functions as expected.

I also came across the following bug:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=337422

Perhaps they're related?
Re: The parameter name in the query's selection criteria does not match any parameter name defined i [message #658949 is a reply to message #657595] Thu, 10 March 2011 14:39 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

By removing ENABLE_SELECTIVE you are making caching enabled for everything, so then probably do not hit the database for this query.

Does this query/relationship ever work? From an empty cache (restart app or clear cache), can you read the object and access the relationship?

Try putting a breakpoint in the exception, what is the context of the translationRow when this error occurs?


James : Wiki : Book : Blog : Twitter
Re: The parameter name in the query's selection criteria does not match any parameter name defined i [message #658960 is a reply to message #658949] Thu, 10 March 2011 15:00 Go to previous messageGo to next message
Andrew Rustleund is currently offline Andrew Rustleund
Messages: 6
Registered: March 2011
Junior Member
Yes, this relationship works in every other case that I have used it in.

The sticking point seems to be setting a previously merged entity (with Collection properties) as a property of a new instance of a different entity, and then attempting to merge that new instance.
Re: The parameter name in the query's selection criteria does not match any parameter name defined i [message #658980 is a reply to message #658949] Thu, 10 March 2011 15:31 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 807
Registered: July 2009
Senior Member
I have my shared cache disabled completely (JPA runs in fat clients).
Re: The parameter name in the query's selection criteria does not match any parameter name defined i [message #660756 is a reply to message #657595] Mon, 21 March 2011 13:41 Go to previous messageGo to next message
James Trotman is currently offline James Trotman
Messages: 2
Registered: March 2011
Junior Member
I've encountered this issue as well. It certainly seems to be a regression bug, given that it works in earlier versions. Has an issue ticket been raised for this?
Re: The parameter name in the query's selection criteria does not match any parameter name defined i [message #907281 is a reply to message #660756] Mon, 03 September 2012 16:47 Go to previous message
Nuno Godinho de Matos is currently offline Nuno Godinho de Matos
Messages: 1
Registered: September 2012
Junior Member
In the case I have experienced the navigation definitions were all correct, and there was no bug related to the capslock of the referenced column.

Basically, it seems that eclipselink expectes for atleast one of your @joincolumn annotations to not be flagged as readonly. (e.g. if, (a) all your join columns are NOT falgged as readonly, that is the fields are insertable and updatable, you will get the error stating that you cannot have more than one joincolumn specifying the the target field as wrtiable; (b) if all your joinColumns are flagged as readonly, you will get the error "The parameter name [someField] in the query's selection criteria does not match any parameter name defined in the query.")


To fix it, download the source code, set a break point in the getValue() method that is exploding.

Look at the translation table parameter, see the name of the dabase table contained in this translation object.
Looking at this translation object, you will notice that most of the properties of your database table are contained within it, with the expection of the database FIELD whose name appeared in the exception you obtained.

Finally, find the correnspoding JPA entity that maps to the table in the "translation" parameter and fix the joinColumn annotations in this entity. You must have at least one of them not flagged as read only. (cut away the insertable=false, updatable=false)


Best of luck.

[Updated on: Tue, 04 September 2012 06:42]

Report message to a moderator

Previous Topic:Retrieve server generated value
Next Topic:Implementing post merge events
Goto Forum:
  


Current Time: Sat Oct 25 08:02:15 GMT 2014

Powered by FUDForum. Page generated in 0.03067 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software