Hibernate version:
3.2
Mapping documents:
InstrumentDescription
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="false" default-cascade="all-delete-orphan" default-lazy="false">
<class name="com.calyon.edtp.services.messages.InstrumentDescription" table="InstrumentDescription">
<id name="Code" type="org.hibernate.type.StringType">
<generator class="assigned"/>
</id>
<discriminator type="org.hibernate.type.StringType">
<column name="Hjtype"/>
</discriminator>
<version name="Hjversion" type="org.hibernate.type.LongType"/>
<subclass discriminator-value="com.calyon.edtp.services.messages.InstrumentDescription" name="com.calyon.edtp.services.messages.impl.InstrumentDescriptionImpl"/>
</class>
</hibernate-mapping>
InstrumentSwapDescription
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="false" default-cascade="all-delete-orphan" default-lazy="false">
<subclass extends="com.calyon.edtp.services.messages.InstrumentDescription" name="com.calyon.edtp.services.messages.InstrumentSwapDescription">
<join table="InstrumentSwapDescription">
<key>
<column name="Hjid"/>
</key>
<property name="Index">
<column name="SwapIndex"/>
<type name="org.hibernate.type.StringType"/>
</property>
<property name="MaturityDate">
<column name="MaturityDate"/>
<type name="org.hibernate.type.StringType"/>
</property>
<property name="GroupId">
<column name="GroupId"/>
<type name="org.hibernate.type.StringType"/>
</property>
<property name="Maturity">
<column name="Maturity"/>
<type name="org.hibernate.type.StringType"/>
</property>
<property name="Label">
<column name="Label"/>
<type name="org.hibernate.type.StringType"/>
</property>
<property name="Currency">
<column name="Currency"/>
<type name="org.hibernate.type.StringType"/>
</property>
<property name="MaturitySort">
<column name="MaturitySort"/>
<type name="org.hibernate.type.StringType"/>
</property>
<property name="Term">
<column name="Term"/>
<type name="org.hibernate.type.StringType"/>
</property>
</join>
<subclass discriminator-value="com.calyon.edtp.services.messages.InstrumentSwapDescription" name="com.calyon.edtp.services.messages.impl.InstrumentSwapDescriptionImpl"/>
</subclass>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Criteria criteria = session.createCriteria(InstrumentDescription.class);
List list = criteria.list();
Full stack trace of any exception that occurs:
org.hibernate.InstantiationException: Cannot instantiate abstract class or interface: com.calyon.edtp.services.messages.InstrumentSwapDescription
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:78)
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:100)
at org.hibernate.tuple.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:344)
at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:3469)
at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1242)
at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1231)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1291)
at org.hibernate.loader.Loader.getRow(Loader.java:1197)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:569)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1536)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at com.calyon.edtp.services.instrument.InstrumentManager.snapshotInstruments(InstrumentManager.java:83)
at com.calyon.edtp.services.instrument.InstrumentManager.onInstrumentMessage(InstrumentManager.java:59)
at com.calyon.edtp.services.Service.switchMessage(Service.java:105)
at com.calyon.edtp.services.Service.onMessage(Service.java:89)
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:393)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:365)
at org.springframework.jms.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:345)
at org.springframework.jms.listener.SimpleMessageListenerContainer$1.onMessage(SimpleMessageListenerContainer.java:129)
at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:717)
at org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:96)
at org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:149)
at org.apache.activemq.thread.SimpleTaskRunner.runTask(SimpleTaskRunner.java:110)
at org.apache.activemq.thread.SimpleTaskRunner.access$100(SimpleTaskRunner.java:25)
at org.apache.activemq.thread.SimpleTaskRunner$1.run(SimpleTaskRunner.java:43)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)
Name and version of the database you are using:
Sybase 12.5
The generated SQL (show_sql=true):
select
this_.Code as Code18_0_,
this_.Hjversion as Hjversion18_0_,
this_1_.SwapIndex as SwapIndex22_0_,
this_1_.MaturityDate as Maturity3_22_0_,
this_1_.GroupId as GroupId22_0_,
this_1_.Maturity as Maturity22_0_,
this_1_.Label as Label22_0_,
this_1_.Currency as Currency22_0_,
this_1_.MaturitySort as Maturity8_22_0_,
this_1_.Term as Term22_0_,
this_.Hjtype as Hjtype18_0_
from
InstrumentDescription this_
left outer join
InstrumentSwapDescription this_1_
on this_.Code=this_1_.Hjid
Debug level Hibernate log excerpt:
I'm using hyperjaxb2 to generate java classes and hibernate mapping from an xsd. It generates 2 interfaces : InstrumentDescription and InstrumentSwapDescription with the second extending the first. Il also generates InstrumentDescriptionImpl and InstrumentSwapDescriptionImpl which are the two concrete classes implementing the interfaces.
When trying to query all InstrumentDescription, it results in a InstantiationException "Cannot instantiate abstract class or interface com.calyon.edtp.services.messages.InstrumentSwapDescription"
I can't figure why this error happen as the name of the subclass in the mapping is set to the concrete implementing class "InstrumentSwapDescriptionImpl"
I'm probably missing something but I can't find what. Any help will be appreciate.
Thanks
PS: The hibernate generated query executed on the database by hand result in a valid resultset
|