Hibernate 3.0.3
I have created a mapping file that contains a hierarchy of abstract and concrete subclasses and a parallel hierarchy of interfaces (for use as proxies). I saw nothing in particular in the documentation that discouraged this. An example mapping:
<hibernate-mapping>
<!-- Root interface -->
<class name="AddressIF"
table="ADDRESS" proxy="AddressIF">
<meta attribute="interface" inherit="false">true</meta>
<id name="addressId" type="long" column="ADDRESS_ID"/>
<discriminator column="ADDRESS_TYPE" type="string" length="30"/>
<many-to-one name="server" column="SERVER_ID" class="ServerIF" not-null="true" />
<!-- Subclass interfaces -->
<subclass name="SubAddressIF"
discriminator-value="null" proxy="SubAddressIF">
<meta attribute="interface" inherit="false">true</meta>
<property name="subProp" column="PROP" />
<subclass name="SubSubAddressIF"
discriminator-value="null" proxy="SubSubAddressIF">
<meta attribute="interface" inherit="false">true</meta>
<property name="subsubProp" column="PROPPROP" />
</subclass>
</subclass>
<!-- Subclass implementations -->
<subclass name="AbstractAddressImpl"
abstract="true" discriminator-value="null" proxy="AddressIF">
<meta attribute="scope-class" inherit="false">public abstract</meta>
<subclass name="SubAddressImpl"
discriminator-value="sub" proxy="SubAddressIF">
<subclass name="SubSubAddressImpl"
discriminator-value="subsub" proxy="SubSubAddressIF"/>
</subclass>
</subclass>
</class>
At startup, Hibernate throws a unusual Exception related to the interface hierarchy:
Quote:
java.util.NoSuchElementException at java.util.AbstractList$Itr.next(AbstractList.java:426) at org.hibernate.sql.InFragment.toFragmentString(InFragment.java:80) at org.hibernate.persister.entity.SingleTableEntityPersister.discriminatorFilterFragment(SingleTableEntityPersister.java:495) at org.hibernate.persister.entity.SingleTableEntityPersister.filterFragment(SingleTableEntityPersister.java:467) at org.hibernate.persister.entity.BasicEntityPersister.filterFragment(BasicEntityPersister.java:2230) at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:85) at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:59) at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:49) at org.hibernate.loader.entity.BatchingEntityLoader.createBatchingEntityLoader(BatchingEntityLoader.java:103) at org.hibernate.persister.entity.BasicEntityPersister.createEntityLoader(BasicEntityPersister.java:1421) at org.hibernate.persister.entity.BasicEntityPersister.createEntityLoader(BasicEntityPersister.java:1425) at org.hibernate.persister.entity.BasicEntityPersister.createLoaders(BasicEntityPersister.java:2429) at org.hibernate.persister.entity.BasicEntityPersister.postInstantiate(BasicEntityPersister.java:2422) at org.hibernate.persister.entity.SingleTableEntityPersister.postInstantiate(SingleTableEntityPersister.java:656) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:242) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1055)
It seems that Hibernate doesn't like the fact that each interface in the hierarchy doesn't conclude with a concrete class. If I place a dummy concrete subclass after each interface, then everything is peachy. Is it unreasonable for Hibernate to allow such hierarchies of interfaces?
Even if my mapping structure is completely whacked (I would appreciate comments on that), I think that Hibernate should throw a more relevant Exception than 'java.util.NoSuchElementException'
I looked at the code (InFragment.java), and the if-else block doesn't handle the condition of an empty arraylist of values, even though it appears possible.
Should I send that through JIRA?