I'm using hibernate 3.1 and have the following mapping file:
Code:
<hibernate-mapping package="gov.seahawk.model">
<class name="DataSource" table="DATA_SOURCE">
<id name="key" type="string" column="ID">
<generator class="guid"/>
</id>
<property name="name" type="string" column="NAME"/>
<property name="shortName" type="string" column="SHORT_NAME"/>
<property name="description" type="string" column="DESCRIPTION"/>
<set name="dataSourceRanks" table="DATA_SOURCE_RANKS">
<key column="DATA_SOURCE_ID" foreign-key="DATA_SOURCE_RANKS_DATA_SOURCE_ID_FK"/>
<composite-element class="DataSourceRank">
<property name="className" type="string" column="CLASS_NAME"/>
<property name="propertyName" type="string" column="PROPERTY_NAME"/>
<property name="rank" type="integer" column="RANK"/>
</composite-element>
</set>
</class>
</hibernate-mapping>
And the following HQL query:
Code:
<hibernate-mapping>
<query name="dbo.DataSource.findByShortName">
<![CDATA[
from DataSource as ds
join fetch ds.dataSourceRanks
where ds.shortName = :shortName
]]>
</query>
</hibernate-mapping>
My java code:
Code:
Query query = sessionFactory.getCurrentSession()
.getNamedQuery("dbo.DataSource.findByShortName");
query.setString("shortName", name);
resultSet = query.list();
if (resultSet.size() == 1) {
ds = (DataSource) resultSet.get(0);
vessel = assignDataSource(ds, vessel);
return vessel;
}
What I expected was a single DataSource object in the list with its dataSourceRanks collection initialized. What I received was a list of 28 records. I'm confused by the query results. It appears to be more like a SQL result set and not the object with its value collection initialized. I need some help understanding the behavior I'm observing and what I must do to return a DataSource object with its value collection intialized.
Thanks,
Grant