[1.2.4] IllegalArgumentException: org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters.

3,448 views
Skip to first unread message

James

unread,
Nov 30, 2011, 12:15:38 AM11/30/11
to play-fr...@googlegroups.com
Hey guys, I encountered this error in my application when I switched Play version from 1.2.3 to 1.2.4. It's working in 1.2.3 but gives me exception in 1.2.4.

This is the example of the URL I'm calling. "http://localhost:9000/projectUrl?profile.id=123". 

This is the action the URL mapped to.

public static void profile(Profile profile){

.....

}

This is the stack trace.
play.exceptions.UnexpectedException: Unexpected Error
at play.db.jpa.JPAPlugin.bind(JPAPlugin.java:66)
at play.plugins.PluginCollection.bind(PluginCollection.java:534)
at play.data.binding.Binder.bind(Binder.java:111)
at play.mvc.ActionInvoker.getActionMethodArgs(ActionInvoker.java:642)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 2
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:440)
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:72)
at play.db.jpa.JPAPlugin.bind(JPAPlugin.java:59)
... 7 more
Caused by: org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 2
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:81)
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:87)
at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:444)
at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:416)
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:434)
... 9 more
 
Thanks.

christian sarnataro

unread,
Nov 30, 2011, 5:02:16 AM11/30/11
to play-fr...@googlegroups.com
Could you please provide Profile class code?

Nicolas Leroux

unread,
Nov 30, 2011, 9:41:01 AM11/30/11
to play-fr...@googlegroups.com
Hi could you provide more info? 

Model class and controller?

Thanks

Nicolas
On Nov 30, 2011, at 11:02 AM, christian sarnataro wrote:

Could you please provide Profile class code?

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/Esfcfp49PI0J.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

James

unread,
Dec 1, 2011, 4:21:48 AM12/1/11
to play-fr...@googlegroups.com
Sorry for the late reply. I'm using the latest 1.2.x source code and I've managed to trace the source of the problem. It's from play.mvc.ActionInvoker#invoke. Params are merged at line 115 and merged again at line 161. This two merging returns a map with key "id" and values. ["1234","1234"], which should be only one value. Any idea? Thanks.

Nicolas Leroux

unread,
Dec 1, 2011, 4:23:25 AM12/1/11
to play-fr...@googlegroups.com
Yes, I think I have just fixed it. Can you pull again and try it? 

Thanks

Nicolas
On Dec 1, 2011, at 10:21 AM, James wrote:

Sorry for the late reply. I'm using the latest 1.2.x source code and I've managed to trace the source of the problem. It's from play.mvc.ActionInvoker#invoke. Params are merged at line 115 and merged again at line 161. This two merging returns a map with key "id" and values. ["1234","1234"], which should be only one value. Any idea? Thanks.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/619Z9K6Pfk4J.

James

unread,
Dec 1, 2011, 5:34:04 AM12/1/11
to play-fr...@googlegroups.com
Yes. It's working now. Thanks Nicolas.

James

unread,
Jan 25, 2012, 11:47:00 PM1/25/12
to play-fr...@googlegroups.com
Hi Nicolas, 

 I'm having another problem related to this issue. This is the model I have.

@Entity
@Table(name="EXAMPLE")
public class Example extends GenericModel {
@Id
@Required
public String code;
...
}
 

This is the controller.

public static void example(Example example) {
//do validation here
if(!validation.hasErrors()){
 example.save();
}
render(example);
}

This is the markup.
....
#{form @example().add('example.code', example?.code), enctype:'multipart/form-data'} 
...
#{/form}
...

Let's say because of failed validation, I rendered a transient object back to markup and I tried to save again. When Play binder binds it, it'll add code as a new value. i.e.  I'll get something like this code = ["1234","1234"] which is wrong in this case because I'm editing the existing object and code should be ["1234"] only. Is something wrong with my code or is it a bug from Play? Can you kindly validate please? Thanks a lot.

Morten Kjetland - committer

unread,
Jan 27, 2012, 7:50:04 AM1/27/12
to play-fr...@googlegroups.com
If you think this is a bug, please file a new ticket.

and please include a working project showing the problem.. That way it is more easy for us to find and fix the problem.

-morten
Reply all
Reply to author
Forward
0 new messages