title: Hibernate query.getResultList() exception
body: <p><code>query.getResultList()</code> is failing for the following piece of code.</p>
  
  <pre><code>Query query=EntityManager.createQuery("select m from AbstractGasTrade m");
  List&lt;T&gt; resultList = query.getResultList();
  </code></pre>
  
  <p>It throws following exception </p>
  
  <blockquote>
    <p>javax.persistence.PersistenceException:
    org.hibernate.InstantiationException:
    Cannot instantiate abstract class or
    interface:
    com.pse.lib.trading.energy.naturalgas.AbstractGasTrade
      at
    org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
      at
    org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:76)
      at
    com.pse.lib.db.dao.GenericDao.findAll(GenericDao.java:68)
      at
    com.pse.lib.db.logic.GenericManager.findAll(GenericManager.java:75)
      at
    com.pse.lib.db.logic.GenericManager.findAll(GenericManager.java:86)
      at
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native
    Method)   at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at
    java.lang.reflect.Method.invoke(Method.java:597)
      at
    org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
      at
    org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      at
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      at
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
      at
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      at $Proxy29.findAll(Unknown Source)
      at
    com.pse.katana.services.possvc.PositionService.createPositionSegment(PositionService.java:180)
      at
    com.pse.katana.services.possvc.PositionService.handlePositionSubscription(PositionService.java:150)
      at
    com.pse.katana.services.possvc.PositionService.accept(PositionService.java:243)
      at
    com.pse.katana.messages.PositionSubscriptionRequest.visit(PositionSubscriptionRequest.java:43)
      at
    com.pse.katana.services.possvc.PositionService.dispatch(PositionService.java:266)
      at
    com.pse.lib.servicengine.processor.AsynchronousOperation.run(AsynchronousOperation.java:42)
      at
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at
    java.lang.Thread.run(Thread.java:662)
    Caused by:
    org.hibernate.InstantiationException:
    Cannot instantiate abstract class or
    interface:
    com.pse.lib.trading.energy.naturalgas.AbstractGasTrade
      at
    org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:101)
      at
    org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:123)
      at
    org.hibernate.tuple.entity.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:374)
      at
    org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:3634)
      at
    org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1302)
      at
    org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1291)
      at
    org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1323)
      at
    org.hibernate.loader.Loader.getRow(Loader.java:1230)
      at
    org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:603)
      at
    org.hibernate.loader.Loader.doQuery(Loader.java:724)
      at
    org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
      at
    org.hibernate.loader.Loader.doList(Loader.java:2228)
      at
    org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
      at
    org.hibernate.loader.Loader.list(Loader.java:2120)
      at
    org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
      at
    org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
      at
    org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
      at
    org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
      at
    org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
      at
    org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67)
      ... 23 more</p>
  </blockquote>
  
  <p>It happens when one of the joined column has null value.</p>
  
  <pre><code>@JoinColumn(name = "PayDescriptor")
  @ManyToOne(cascade = CascadeType.ALL)
  private GasTradeDescriptor tradePriceDescriptor;
  </code></pre>
  
  <p>Problem is that we want to ignore the values for which joined column has null values and want to continue loading remaining non-null values. For null values we just want to log the message. We are not sure about the best possible approach to tackle this. Any idea or suggestion about the best approach will be much appreciated.</p>
  
  <p>Many thanks in advance.</p>
  
  <p>Rab</p>