I'm trying to use the "Table per concrete class" inheritance functionality. The example in the hibernate docs (
http://www.hibernate.org/hib_docs/v3/re ... strategies) is this:
<class name="Payment">
<id name="id" type="long" column="PAYMENT_ID">
<generator class="native"/>
</id>
<property name="amount" column="AMOUNT"/>
...
<union-subclass name="CreditCardPayment" table="CREDIT_PAYMENT">
<property name="creditCardType" column="CCTYPE"/>
...
</union-subclass>
<union-subclass name="CashPayment" table="CASH_PAYMENT">
...
</union-subclass>
<union-subclass name="ChequePayment" table="CHEQUE_PAYMENT">
...
</union-subclass>
</class>
And yet, when I look at UnionSubclassEntityPersister, line 61, I see this:
if ( getIdentifierGenerator() instanceof IdentityGenerator ) {
throw new MappingException(
"Cannot use identity column key generation with <union-subclass> mapping for: " + getEntityName());
}
I'm guessing the docs are wrong since the code prohibits this quite clearly. Anybody know why this is prohibited?
Thanks,
Max
Hibernate version:
3.0.2
Mapping documents:
<class name="Base">
<id name="val" column="val" type="integer">
<generator class="identity"/>
</id>
<union-subclass name="Child1" table="Child1">
<property name="val1" column="val1" not-null="false"/>
</union-subclass>
<union-subclass name="Child2" table="Child2">
<property name="val2" column="val2" not-null="false"/>
</union-subclass>
</class>
Full stack trace of any exception that occurs:
Caused by: org.hibernate.MappingException: Cannot use identity column key generation with <union-subclass> mapping for: Child1
at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:61)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:61)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
Name and version of the database you are using:MySql 4