[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2468) Is setParameter 0- or 1-based?

Bruno Ledesma (JIRA) noreply at atlassian.com
Mon Aug 6 10:05:11 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27750 ] 

Bruno Ledesma commented on HHH-2468:
------------------------------------

by the way, this is the query: 'from User where username = ? and password = ?'
im binding the parameters 0-based. it works on the IDE and don´t work when java -jar invoking.  The problem seems to be happening in all Hibernate 3.2.x versions. the jdk is 6.0 as the issue describes too.

> Is setParameter 0- or 1-based?
> ------------------------------
>
>                 Key: HHH-2468
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2468
>             Project: Hibernate3
>          Issue Type: Bug
>    Affects Versions: 3.2.2
>         Environment: Hibernate 3.2.2.GA, RDBMS: H2, version: 1.0 (2007-01-30), JDK 6.0, Windows XP Pro
>            Reporter: Rafael Borges
>            Priority: Trivial
>
> The following query throws a wrong message in the Exception
> == Query ==
> query = session.createQuery("select t from Test t where t.id = ?");
> query.setParameter(1, 1);
> == Message ==
> Exception in thread "main" java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!
> 	at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:55)
> 	at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:61)
> 	at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:397)
> 	at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:369)
> 	at Test.main(Test.java:25)
> The Javadoc says it is 0-based, and that works perfectly when used accordingly. So I think it is just a comestic fix.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       




More information about the hibernate-issues mailing list