• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

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

<class name="com.msdw.pbefficiency.servicestracker.Opportunity" table="OPPORTUNITY">
<id name="id" column="OPPID">
<generator class="identity"/>
<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" />
<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

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?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!