Solved

Retrieving data generated in a HQL query

Posted on 2006-10-23
1
248 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
Comment Utility

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
network + 7 72
countPairs challenge 7 57
json format text only 4 64
Groovy:unable to resolve class error 2 27
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now