java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!

hibernate.org | 4 months ago
  1. 0

    Hibernate can't handle CTE, so to make a CTE work, I have to create a class with subselect: <class name="foo"> <subselect><![CDATA[ select a.columnA from TableA a where a.columnB = ? ]]></subselect> . . . </class> Then in my code: List result=session.createQuery("from foo").setParameter(0,"baa").list(), it always report error: 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:382) at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:362) at com.ibm.dztest.businesslogic.TestSQL.main(TestSQL.java:48) If I change the positioned parameter to named parameter, then the problem is: Exception in thread "main" org.hibernate.HibernateException: could not locate named parameter [id] at org.hibernate.engine.query.ParameterMetadata.getNamedParameterDescriptor(ParameterMetadata.java:75) at org.hibernate.engine.query.ParameterMetadata.getNamedParameterExpectedType(ParameterMetadata.java:81) at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:390) at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:376) at com.ibm.dztest.businesslogic.TestSQL.main(TestSQL.java:49) If I put a query without parameter in <subselect>, everything works fine.

    Hibernate JIRA | 1 decade ago | david zhang
    java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!
  2. 0

    Hibernate can't handle CTE, so to make a CTE work, I have to create a class with subselect: <class name="foo"> <subselect><![CDATA[ select a.columnA from TableA a where a.columnB = ? ]]></subselect> . . . </class> Then in my code: List result=session.createQuery("from foo").setParameter(0,"baa").list(), it always report error: 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:382) at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:362) at com.ibm.dztest.businesslogic.TestSQL.main(TestSQL.java:48) If I change the positioned parameter to named parameter, then the problem is: Exception in thread "main" org.hibernate.HibernateException: could not locate named parameter [id] at org.hibernate.engine.query.ParameterMetadata.getNamedParameterDescriptor(ParameterMetadata.java:75) at org.hibernate.engine.query.ParameterMetadata.getNamedParameterExpectedType(ParameterMetadata.java:81) at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:390) at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:376) at com.ibm.dztest.businesslogic.TestSQL.main(TestSQL.java:49) If I put a query without parameter in <subselect>, everything works fine.

    Hibernate JIRA | 1 decade ago | david zhang
    java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!
  3. 0

    Hibernate Community • View topic - HQL: How use a parameter in a like %foo% expression?

    hibernate.org | 4 months ago
    java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    HQL - Remember that ordinal parameters are 1-based?

    Stack Overflow | 5 years ago | emeraldjava
    java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!
  6. 0

    a hibernate bug?

    Stack Overflow | 5 years ago | Crystal Cat
    java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IndexOutOfBoundsException

      Remember that ordinal parameters are 1-based!

      at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor()
    2. Hibernate
      AbstractQueryImpl.setParameter
      1. org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:55)
      2. org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:61)
      3. org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:382)
      4. org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:362)
      4 frames