Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the type of object returned by a named query?

 
Juzar Roopawalla
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have the following structure:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.msdw.pbefficiency.servicestracker.Opportunity" table="OPPORTUNITY">
<id name="id" column="OPPID">
<generator class="identity"/>
</id>
<property name="name" column="NAME" not-null="true"/>
<set name="projectList" cascade="save-update" lazy="false">
<key column="OPPID" not-null="true" />
<one-to-many class="com.msdw.pbefficiency.servicestracker.Project" />
</set>
</class>
<sql-query name="n1">
<return alias="opp" class="com.msdw.pbefficiency.servicestracker.Opportunity"/>
<return-join alias="proj" property="opp.projectList"/>
select * from OPPORTUNITY o, PROJECT p where o.OPPID = p.OPPID
</sql-query>
</hibernate-mapping>

Opprotunity.java has a property called projectList of type Set.

When I execute the query like this:

Query q = session.getNamedQuery( "n1" );
List<Opportunity> entries = q.list();

The List returned is of type 'Object' and not Opportunity.
Is there some kind of additional parameter in the mapping file that I have to set. I have read the docs and there is nothing additional that was required. Could someone please help me out?

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic