title: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query with oracle
body: <p>I am trying to delete or select data from table, for it I am using Spring data JPA.</p>
  
  <p>Exception I am facing is "<code>javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query</code>"</p>
  
  <p>full stack trace given below</p>
  
  <pre class="lang-html prettyprint-override"><code>Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query
      at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763)
      at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677)
      at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:458)
      at org.hibernate.jpa.criteria.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:67)
      at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:291)
      at org.springframework.data.jpa.repository.support.SimpleJpaRepository.deleteAll(SimpleJpaRepository.java:198)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:416)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:401)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:373)
      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$CrudMethodMetadataPopulatingMethodIntercceptor.invoke(CrudMethodMetadataPostProcessor.java:122)
      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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.jbehave.core.steps.StepCreator$MethodInvoker.invoke(StepCreator.java:671)
      at org.jbehave.core.steps.StepCreator$BeforeOrAfterStep.perform(StepCreator.java:458)
      ... 12 more
  Caused by: org.hibernate.exception.GenericJDBCException: could not execute query
      at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
      at org.hibernate.loader.Loader.doList(Loader.java:2557)
      at org.hibernate.loader.Loader.doList(Loader.java:2540)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2370)
      at org.hibernate.loader.Loader.list(Loader.java:2365)
      at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:497)
      at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387)
      at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:236)
      at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264)
      at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
      at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
      at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449)
      ... 42 more
  Caused by: java.sql.SQLException: Fail to convert to internal representation
      at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
      at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:229)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:403)
      at oracle.jdbc.driver.CharCommonAccessor.getLong(CharCommonAccessor.java:252)
      at oracle.jdbc.driver.T4CVarcharAccessor.getLong(T4CVarcharAccessor.java:813)
      at oracle.jdbc.driver.OracleResultSetImpl.getLong(OracleResultSetImpl.java:743)
      at oracle.jdbc.driver.OracleResultSet.getLong(OracleResultSet.java:440)
      at org.apache.commons.dbcp.DelegatingResultSet.getLong(DelegatingResultSet.java:278)
      at org.apache.commons.dbcp.DelegatingResultSet.getLong(DelegatingResultSet.java:278)
      at org.apache.commons.dbcp.DelegatingResultSet.getLong(DelegatingResultSet.java:278)
      at org.hibernate.type.descriptor.sql.BigIntTypeDescriptor$2.doExtract(BigIntTypeDescriptor.java:74)
      at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
      at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:267)
      at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:263)
      at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253)
      at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:338)
      at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2969)
      at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1696)
      at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1628)
      at org.hibernate.loader.Loader.getRow(Loader.java:1515)
      at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:726)
      at org.hibernate.loader.Loader.processResultSet(Loader.java:953)
      at org.hibernate.loader.Loader.doQuery(Loader.java:921)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:355)
      at org.hibernate.loader.Loader.doList(Loader.java:2554)
      ... 52 more
  </code></pre>
  
  
  
  <p>Entity class is mentioned below</p>
  
  <pre class="lang-html prettyprint-override"><code>@Entity
      @Table(name = "EMPLOYEE")
      public class Employee {
  
          @Id
          @Column(name = "ID")
          private Long id;
  
          @Column(name = "EMPLOYEE_ID")
          private Long employeeId;
  
          @Column(name = "EMPLOYEE_TYPE")
          private String employeeType;
  
  
  
          public void setId(Long id) {
              this.id = id;
          }
  
          public void setEmployeeId(Long employeeId) {
              this.employeeId = employeeId;
          }
  
          public void setEmployeeType(String employeeType) {
              this.employeeType = employeeType;
          }
      }
  </code></pre>
  
  
  
  <p>Repository class is </p>
  
  <pre><code>public interface EmployeeRepository extends JpaRepository&lt;EMPLOYEE, Long&gt; {
  }
  </code></pre>
  
  <p>Executing below query</p>
  
  <pre class="lang-html prettyprint-override"><code>EmployeeRepository empRepo;
  empRepo.deleteAll();
  </code></pre>
  
  
  
  <p>table design is given below</p>
  
  <pre class="lang-html prettyprint-override"><code>    CREATE TABLE DB.EMPLOYEE
  (
    ID              NUMBER(19)                    NOT NULL,
    EMPLOYEE_ID       VARCHAR2(255 CHAR),
    EMPLOYEE_TYPE  VARCHAR2(255 CHAR)
  )
  </code></pre>
  
  
  
  <p>Please suggest.</p>