-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate query.getResultList() exception
PostPosted: Wed Jun 22, 2011 4:45 pm 
Newbie

Joined: Wed Jun 22, 2011 4:41 pm
Posts: 1
query.getResultList() is failing for the following piece of code.

Query query=EntityManager.createQuery("select m from AbstractGasTrade m");
List<T> resultList = query.getResultList();

It throws following exception


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


It happens when one of the joined column has null value.

@JoinColumn(name = "PayDescriptor")
@ManyToOne(cascade = CascadeType.ALL)
private GasTradeDescriptor tradePriceDescriptor;

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.

Many thanks in advance.

Rab


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.