Hibernate version:
3.2.4.sp1
Hibernate annotations/em version:
3.2.1.ga
Mapping documents:
Most JPA mapping are annotated on the class itself except the @Table and @Inheritance is put in orm.xml.
An entity at the root of the inheritance heirarchy suing table per heirarchy approach -
Code:
<entity class="com.domain.A" name="A">
<table name="A"/>
<inheritance strategy="SINGLE_TABLE"/>
<discriminator-column name="DISCRIMINATOR" discriminator-type="STRING"/>
</entity>
An entity part of table per heirarchy inheritance but not the root parent. Root parent is A
Code:
<entity class="com.domain.B" name="B"></entity>
An entity not participating in Table per Heirarchy and using Joined Subclass.
Code:
<entity class="com.domain.C" name="C">
<table name="C"/>
<inheritance strategy="JOINED"/>
</entity>
exception that occurs:ORA SQL Grammar exception.
Name and version of the database you are using:Oracle 10g
The generated SQL (show_sql=true):Not using hibernates SQL generation, but have checked that the databse has the column name correctly set to DISCRIMINATOR.
Debug level Hibernate log excerpt:Code:
insert
into
A
(ATTR, CREATEDBY, CREATIONDATE, LASTMODIFICATIONDATE, LASTMODIFIEDBY, uuid, VERSION, DTYPE, ID)
values
(?, ?, ?, ?, ?, ?, ?, 'A', ?)
02:04:03,494 WARN [JDBCExceptionReporter] SQL Error: 904, SQLState: 42000
02:04:03,494 ERROR [JDBCExceptionReporter] ORA-00904: "DTYPE": invalid identifier
So, it’s trying to use DTYPE (hibernate’s default) as the discriminator column rather than DISCRIMINATOR.
Any idea why its ignoring the column specified in the orm.xml and using the hibernate default? When I change the SQL to use DTYPE rather than DISCRIMINATOR, all works fine. Also the entities that dont use table per heirarchy but rather joined subclass work fine.
So is there some wrong syntax in my orm.xml?
Thanks