• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic