java.lang.ArrayIndexOutOfBoundsException: 1

Hibernate JIRA | jerome bonnet | 1 decade ago
  1. 0

    I am triggered an ArrayIndexOutOfBound Exception in the hibernate code. This happens when I try to bind a positional parameter of type object. For instance: List finds = session.find("from package.MyClass as myclass where myclass.myAttrib=?", subobject, Hibernate.OBJECT); where myclass.myAttrib is a many-to-one relationship to subobject. The stacktrace is: java.lang.ArrayIndexOutOfBoundsException: 1 at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2005) at com.mysql.jdbc.PreparedStatement.setBytes(PreparedStatement.java:493) at net.sf.hibernate.type.BinaryType.set(BinaryType.java:28) at net.sf.hibernate.type.SerializableType.set(SerializableType.java:28) at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48) at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35) at net.sf.hibernate.type.ObjectType.nullSafeSet(ObjectType.java:144) at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:674) at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:713) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:185) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133) at net.sf.hibernate.loader.Loader.doList(Loader.java:950) at net.sf.hibernate.loader.Loader.list(Loader.java:941) at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1487) Using a debugger I have found that the index is 2 instead of 1 in PreparedStatement.setByte Of course this cannot work and should come from hibernate mapping. Debugging a little further I have found that in ObjectType.nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) I think that there is an error: metaType.nullSafeSet(st, clazz, index, session); identifierType.nullSafeSet(st, id, index+1, session); // metaType must be single-column type ^^^^^^^^^^^^^ ^^^^^^ The index+1 is wrong it should be index. I am not sure but I think the other types does not have such +1...

    Hibernate JIRA | 1 decade ago | jerome bonnet
    java.lang.ArrayIndexOutOfBoundsException: 1
  2. 0

    I am triggered an ArrayIndexOutOfBound Exception in the hibernate code. This happens when I try to bind a positional parameter of type object. For instance: List finds = session.find("from package.MyClass as myclass where myclass.myAttrib=?", subobject, Hibernate.OBJECT); where myclass.myAttrib is a many-to-one relationship to subobject. The stacktrace is: java.lang.ArrayIndexOutOfBoundsException: 1 at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2005) at com.mysql.jdbc.PreparedStatement.setBytes(PreparedStatement.java:493) at net.sf.hibernate.type.BinaryType.set(BinaryType.java:28) at net.sf.hibernate.type.SerializableType.set(SerializableType.java:28) at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48) at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35) at net.sf.hibernate.type.ObjectType.nullSafeSet(ObjectType.java:144) at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:674) at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:713) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:185) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133) at net.sf.hibernate.loader.Loader.doList(Loader.java:950) at net.sf.hibernate.loader.Loader.list(Loader.java:941) at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1487) Using a debugger I have found that the index is 2 instead of 1 in PreparedStatement.setByte Of course this cannot work and should come from hibernate mapping. Debugging a little further I have found that in ObjectType.nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) I think that there is an error: metaType.nullSafeSet(st, clazz, index, session); identifierType.nullSafeSet(st, id, index+1, session); // metaType must be single-column type ^^^^^^^^^^^^^ ^^^^^^ The index+1 is wrong it should be index. I am not sure but I think the other types does not have such +1...

    Hibernate JIRA | 1 decade ago | jerome bonnet
    java.lang.ArrayIndexOutOfBoundsException: 1
  3. 0

    ArrayIndexOutOfBounds When Splitting String

    Stack Overflow | 4 years ago | n0shadow
    java.lang.ArrayIndexOutOfBoundsException: 1
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    ArrayIndexOutOfBoundsException occurring when program running

    Stack Overflow | 4 years ago | dharma
    java.lang.ArrayIndexOutOfBoundsException: 1
  6. 0

    Parsing Data from CSV to Array in Java

    Stack Overflow | 5 years ago
    java.lang.ArrayIndexOutOfBoundsException: 1

    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.ArrayIndexOutOfBoundsException

      1

      at com.mysql.jdbc.PreparedStatement.setInternal()
    2. MySQL jdbc
      PreparedStatement.setBytes
      1. com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2005)
      2. com.mysql.jdbc.PreparedStatement.setBytes(PreparedStatement.java:493)
      2 frames
    3. net.sf.hibernate
      SessionImpl.find
      1. net.sf.hibernate.type.BinaryType.set(BinaryType.java:28)
      2. net.sf.hibernate.type.SerializableType.set(SerializableType.java:28)
      3. net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
      4. net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
      5. net.sf.hibernate.type.ObjectType.nullSafeSet(ObjectType.java:144)
      6. net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:674)
      7. net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:713)
      8. net.sf.hibernate.loader.Loader.doQuery(Loader.java:185)
      9. net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
      10. net.sf.hibernate.loader.Loader.doList(Loader.java:950)
      11. net.sf.hibernate.loader.Loader.list(Loader.java:941)
      12. net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
      13. net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
      14. net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491)
      15. net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1487)
      15 frames