Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Retrieving data generated in a HQL query

Posted on 2006-10-23
1
252 Views
Last Modified: 2006-11-18
How do I retrieve the results of a Query, in Hibernate, that returns multiple object types in the resultset. I am trying to run the following query:

   Select
        l.trackingNumber.retrieveLocalSource(),
        l.queue.getGroup().retrieveRootParentGroup(),
        l.Leads
   From
        ROSLeadImports l
   Where l.leadDT between ? and ?

With the first column being of type Source, the second of type Groups, and the last is an Integer. I have been able to retrieve data when I would run something like "From ROSLeadImports l Where l.leadDT between ? and ?" by running the iterate() function on the Query and casting the resulting objects to type ROSLeadImports; but what if I have a objects with various types?
0
Comment
Question by:rufassa
1 Comment
 
LVL 8

Accepted Solution

by:
reach2piyush earned 250 total points
ID: 17793016

List qryList = query.list();

for (Iterator iter = qryList.iterator(); iter.hasNext();)
{
            Object[] objArray = (Object[]) iter.next();

            Source src = (Source) objArray[0];
            Groups groups = (Groups) objArray[1];
            Integer leads = (Integer) objArray[2];
}
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question