java.lang.ArrayIndexOutOfBoundsException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Please Point Out My Mistakes.
    via by 843854,
  • 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...
    via by jerome bonnet,
  • 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...
    via by jerome bonnet,
    • java.lang.ArrayIndexOutOfBoundsException: 26 at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2127) at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2144) at com.mysql.jdbc.PreparedStatement.setInt(PreparedStatement.java:660) at com.privasphere.privalope.db.MySqlSystem.updateUser(MySqlSystem.java:5532)
    No Bugmate found.