title: ArrayIndexOutOfBoundsException when using Spring-Data JPA
body: <p>I have a Spring application that gets data from a MySQL DB using JPA.</p>
  <p>This is the interface repository that I created.</p>
  <pre class="lang-java prettyprint-override"><code>@Repository
  public interface PhoneRepository extends JpaRepository&lt;Phone, Long&gt; {
     List&lt;Phone&gt; findByUrl(String url);
     List&lt;Phone&gt; findByBrand(String brand);
  }
  </code></pre>
  <p>If I try to access the repository and get data using something like</p>
  <pre class="lang-java prettyprint-override"><code>phoneRepo.findAll();
  </code></pre>
  <p>or</p>
  <pre class="lang-java prettyprint-override"><code>phoneRepo.findByBrand(&quot;SOME TEXT&quot;);
  </code></pre>
  <p>I get the below error:</p>
  <pre><code>SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/gsm-spring] threw exception [Request processing failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 57] with root cause
      java.lang.ArrayIndexOutOfBoundsException: 57
          at com.mysql.cj.mysqla.MysqlaUtils.bitToLong(MysqlaUtils.java:68)
          at com.mysql.cj.core.io.MysqlTextValueDecoder.decodeBit(MysqlTextValueDecoder.java:231)
          at com.mysql.cj.jdbc.ResultSetRow.decodeAndCreateReturnValue(ResultSetRow.java:170)
          at com.mysql.cj.jdbc.ResultSetRow.getValueFromBytes(ResultSetRow.java:269)
          at com.mysql.cj.jdbc.BufferRow.getValue(BufferRow.java:349)
          at com.mysql.cj.jdbc.ResultSetImpl.getNonStringValueFromRow(ResultSetImpl.java:813)
          at com.mysql.cj.jdbc.ResultSetImpl.getBoolean(ResultSetImpl.java:904)
          at com.mysql.cj.jdbc.ResultSetImpl.getBoolean(ResultSetImpl.java:908)
          at org.hibernate.type.descriptor.sql.BooleanTypeDescriptor$2.doExtract(BooleanTypeDescriptor.java:53)
          at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47)
          at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:241)
          at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:237)
          at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:227)
          at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:303)
          at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2726)
          at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1728)
          at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1654)
          at org.hibernate.loader.Loader.getRow(Loader.java:1543)
          at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:727)
          at org.hibernate.loader.Loader.processResultSet(Loader.java:972)
          at org.hibernate.loader.Loader.doQuery(Loader.java:930)
          at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336)
          at org.hibernate.loader.Loader.doList(Loader.java:2611)
          at org.hibernate.loader.Loader.doList(Loader.java:2594)
          at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2423)
          at org.hibernate.loader.Loader.list(Loader.java:2418)
          at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:501)
          at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:371)
          at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:220)
          at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1268)
          at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87)
          at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:567)
          at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:436)
          at org.hibernate.jpa.criteria.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:50)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:362)
          at com.sun.proxy.$Proxy57.getResultList(Unknown Source)
          at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:114)
          at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:78)
          at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:100)
          at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:91)
          at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:454)
          at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:432)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
          at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
          at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
          at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
          at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
          at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
          at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:119)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
          at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
          at com.sun.proxy.$Proxy35.findByBrand(Unknown Source)
          at com.my.test.business.process.MatchPhone.match(MatchPhone.java:67)
          at com.my.test.controllers.ProcessController.processMapping(ProcessController.java:32)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
          at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
          at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
          at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
          at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
          at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
          at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
          at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
          at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
          at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
          at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502)
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
          at java.lang.Thread.run(Unknown Source)
  </code></pre>
  <p>The SQL query that Hibernate creates works fine when I execute it directly on the DB.
  I could not understand the source of the <code>ArrayIndexOutOfBoundsException</code>.
  I tried dropping the DB and re-creating using HBM2DDL to rule out any DB faults. I have other repositories on the same application that work fine, so I ruled out configuration errors too.</p>
  <p>Any help would be appreciated.</p>