Hibernate version: 3.1.2
Mapping file:
Code:
<hibernate-mapping>
<class name="Transaction" table="TRN021" dynamic-update="true" select-before-update="false">
<cache usage="read-write"/>
<id name="transactionId" type="integer">
<column name="TRN021_TRNIDE" precision="22" scale="0" />
<generator class="sequence">
<param name="sequence">TRN021s</param>
</generator>
</id>
<discriminator formula="case when TRN021_TRNTYP in ('*CTR','*CTRADJ') then
TRN021_TRNTYP || case when TRN021_PMEIDE is not null then 'DET' else 'HDR' end
else '*NOSUBCLASS' end" type="string"/>
<version name="_auditSequence" access="field" type="integer">
<column name="TRN021_COFSEQ" not-null="true" />
</version>
<property name="transactionType" type="string">
<column name="TRN021_TRNTYP" length="20" not-null="true" />
</property>
<!-- other properties snipped -->
<subclass name="ContributionAdjustmentDetail" dynamic-update="true" discriminator-value="*CTRADJDET">
<join table="CTR041" fetch="select">
<key column="CTR041_TRNIDE"/>
<property name="headerId" type="int">
<column name="CTR041_HEAIDE"/>
</property>
<property name="contributionId" type="int">
<column name="CTR041_CTRIDE"/>
</property>
<property name="cycleCode" type="string">
<column name="CTR041_CYCCOD" length="20" not-null="false"/>
</property>
<property name="cycleNumber" type="int">
<column name="CTR041_CYCNUM"/>
</property>
</join>
</subclass>
<!-- Other subclasses snipped -->
</class>
</hibernate-mapping>
HQL query: Code:
from ContributionAdjustmentDetail detail
where
detail.headerId = :contributionAdjustmentTransactionId and
detail.status <> '9'
order by detail.contributionId, detail.referenceId
Code executing the query: Code:
Query query = session.createQuery(CONTRIBUTION_ADJUSTMENT_DETAILS_HQL);
query.setInteger("contributionAdjustmentTransactionId", 123);
Iterator<ContributionAdjustmentDetail> iterator = (Iterator<ContributionAdjustmentDetail>) query.iterate();
Closing the iterator returned from the query: Code:
Hibernate.close( iterator );
Full stack trace of any exception that occurs:Code:
java.lang.IllegalArgumentException: not a Hibernate iterator
at org.hibernate.Hibernate.close(Hibernate.java:401)
Hibernate's code in Hibernate.close():Code:
public static void close(Iterator iterator) throws HibernateException {
if ( iterator instanceof HibernateIterator ) {
( ( HibernateIterator ) iterator ).close();
}
else {
throw new IllegalArgumentException( "not a Hibernate iterator" );
}
}
From the above, you can see that I am trying to close an iterator returned from a query. The query happens to involve implicit polymorphism, since I am querying against a subclass that uses the table per subclass using a discriminator inheritance strategy.
The iterator returned was a JoinedIterator, which does not extend HibernateIterator. Thus, when I try to close / cleanup the iterator, I get the exception above.
How can you explicitly close a JoinedIterator so that the ResultSet / etc. are released ?