Is there bug in documentation or hibernate?
I used "Table per concrete class" and try to load object, but I have exception when trying to load Slot instead of SlotElementary.
When I write
SESSION.get( SlotElementary.class, new Integer( slot.getSlot_id() ) );
All works, but when I write
SESSION.get( Slot.class, new Integer( slot.getSlot_id() ) );
I see exception.
Slot is a super-class for all other classes shown here.
Hibernate version: 3.0.3, 3.0.5
Mapping documents:
<class
name="...Slot"
lazy="false"
>
<id
name="slot_id"
column="slot_id"
type="int"
access="field"
>
<generator class="native">
</generator>
</id>
...
<union-subclass
name="...SlotConditionalRelation"
table="Slot_Conditional_Relation"
lazy="false"
>
...
</union-subclass>
<union-subclass
name="...SlotConditionalAttribute"
table="Slot_Conditional_Attribute"
lazy="false"
>
...
</union-subclass>
<union-subclass
name="...AnnotationSlot"
table="ANNOTATION_SLOT"
lazy="false"
>
...
</union-subclass>
<union-subclass
name="...SlotFunctional"
table="slot_functional"
lazy="false"
>
...
</union-subclass>
<union-subclass
name="...SlotRelation"
table="slot_relation"
lazy="false"
>
</union-subclass>
<union-subclass
name="...SlotElementary"
table="slot_elementary"
lazy="false"
>
...
</union-subclass>
</class>
Code between sessionFactory.openSession() and session.close():
SESSION.get( Slot.class, new Integer( slot.getSlot_id() ) );
Full stack trace of any exception that occurs:
org.hibernate.exception.SQLGrammarException: could not load an entity: [ru.vgroup.smt.domain.Slot#5122]
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1359)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
at org.hibernate.loader.entity.BatchingEntityLoader.load(BatchingEntityLoader.java:82)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:351)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:332)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:151)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:621)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:614)
at ru.vgroup.smt.persistence.metadata.hibernate.domain.DomainAbstractTest.loadExists(DomainAbstractTest.java:37)
at ru.vgroup.smt.persistence.metadata.hibernate.domain.DomainAbstractTest.loadSlot(DomainAbstractTest.java:44)
at ru.vgroup.smt.persistence.metadata.hibernate.domain.SlotElementaryTest.testUpdate(SlotElementaryTest.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at ru.vgroup.smt.testframework.smtunit.SMTTestCase.runTest(SMTTestCase.java:114)
at ru.vgroup.smt.testframework.smtunit.SMTTestCase.doRunBare(SMTTestCase.java:97)
at ru.vgroup.smt.testframework.smtunit.SMTTestCase.runBare(SMTTestCase.java:81)
at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: java.sql.SQLException: ORA-00942: <table does not exist>(translation)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:579)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1894)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:831)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2496)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2840)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:536)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1345)
... 39 more
Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
Hibernate: select slot0_.slot_id as slot1_3_, slot0_.frame_id as frame2_11_3_, slot0_.relationpattern_id as relation1_12_3_, slot0_.name as name14_3_, slot0_.metatype_id as metatype1_16_3_, slot0_.name as name16_3_, slot0_.avoidCaching as avoidCac1_17_3_, slot0_.datatype as datatype17_3_, slot0_.code as code17_3_, slot0_.name as name17_3_, slot0_.dontCalculateWhenShow as dontCalc5_17_3_, slot0_.capacityMin as capacity1_18_3_, slot0_.capacityMax as capacity2_18_3_, slot0_.relation_id as relation3_18_3_, slot0_.Measure_Id as Measure1_19_3_, slot0_.DataType as DataType19_3_, slot0_.IdentitySlot as Identity3_19_3_, slot0_.name as name19_3_, slot0_.default_value as default5_19_3_, slot0_.clazz_ as clazz_3_, relationpa1_.relationPattern_id as relation1_0_, relationpa1_.name as name0_0_, relationpa1_.description as descript3_0_0_, relationpa1_.qualifier_id as qualifier4_0_0_, relation2_.relation_id as relation1_1_, relation2_.relationpattern_id as relation2_6_1_, relation2_.framearg1_id as framearg3_6_1_, relation2_.framearg2_id as framearg4_6_1_, measure3_.measure_id as measure1_2_, measure3_.fullName as fullName10_2_, measure3_.shortName as shortName10_2_ from ( select null as Measure_Id, frame_id, null as IdentitySlot, null as relation_id, null as datatype, null as default_value, null as capacityMin, null as metatype_id, null as dontCalculateWhenShow, null as capacityMax, null as avoidCaching, null as code, slot_id, null as name, null as relationpattern_id, 0 as clazz_ from Slot union all select null as Measure_Id, frame_id, null as IdentitySlot, null as relation_id, null as datatype, null as default_value, null as capacityMin, null as metatype_id, null as dontCalculateWhenShow, null as capacityMax, null as avoidCaching, null as code, slot_id, null as name, relationpattern_id, 1 as clazz_ from Slot_Conditional_Relation union all select null as Measure_Id, frame_id, null as IdentitySlot, null as relation_id, null as datatype, null as default_value, null as capacityMin, null as metatype_id, null as dontCalculateWhenShow, null as capacityMax, null as avoidCaching, null as code, slot_id, name, null as relationpattern_id, 2 as clazz_ from Slot_Conditional_Attribute union all select null as Measure_Id, frame_id, null as IdentitySlot, null as relation_id, null as datatype, null as default_value, null as capacityMin, metatype_id, null as dontCalculateWhenShow, null as capacityMax, null as avoidCaching, null as code, slot_id, name, null as relationpattern_id, 3 as clazz_ from ANNOTATION_SLOT union all select null as Measure_Id, frame_id, null as IdentitySlot, null as relation_id, datatype, null as default_value, null as capacityMin, null as metatype_id, dontCalculateWhenShow, null as capacityMax, avoidCaching, code, slot_id, name, null as relationpattern_id, 4 as clazz_ from slot_functional union all select null as Measure_Id, frame_id, null as IdentitySlot, relation_id, null as datatype, null as default_value, capacityMin, null as metatype_id, null as dontCalculateWhenShow, capacityMax, null as avoidCaching, null as code, slot_id, null as name, null as relationpattern_id, 5 as clazz_ from slot_relation union all select Measure_Id, frame_id, IdentitySlot, null as relation_id, datatype, default_value, null as capacityMin, null as metatype_id, null as dontCalculateWhenShow, null as capacityMax, null as avoidCaching, null as code, slot_id, name, null as relationpattern_id, 6 as clazz_ from slot_elementary ) slot0_ left outer join relation_pattern relationpa1_ on slot0_.relationpattern_id=relationpa1_.relationPattern_id left outer join Relation relation2_ on slot0_.relation_id=relation2_.relation_id left outer join Measure measure3_ on slot0_.Measure_Id=measure3_.measure_id where slot0_.slot_id=?
|