Get your CodeRanch badge!*
The moose likes Spring and the fly likes Iterarting ResultSet Conditionally Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Iterarting ResultSet Conditionally" Watch "Iterarting ResultSet Conditionally" New topic
Author

Iterarting ResultSet Conditionally

Pradeep Arun
Greenhorn

Joined: Dec 28, 2007
Posts: 19
Hi,

I am executing a Stored procedure that returns the following resultset.

1, Firstname1, lastname1, homeaddress
1, Firstname1, lastname1, webaddress
1, Firstname1, lastname1, businessaddress
2, Firstname2, lastname2, webaddress
2, Firstname2, lastname2, businessaddress


I am using Spring StoredProcedure and maprow. My Domain object is as below

Class Person {

String firstname;
String lastname;
List address;
}

So one person can have a list of address. But when i use maprow, its returning Object for each record in the resultset where as i need to iterate the resultset conditionally and return it appropriatly. That is i need the maprow to return only after iterating the first three resultset then iterating the next two result set.

is there any way to do this in Spring StoredProcedure? I shouldnt use jdbcTemplate.

Any suggestions?

Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
Not possible and you shouldn't do that. mapRow means map only one row, not many rows.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Pradeep Arun
Greenhorn

Joined: Dec 28, 2007
Posts: 19
agreed. If not maprow what is the other options available.
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
You could group Person by Id later after getting all rows.
pichin pichon
Greenhorn

Joined: Oct 06, 2009
Posts: 2
Pradeep Arun wrote:agreed. If not maprow what is the other options available.



Hi Pradeep,
I have read your post and I try to make something similar,

can you read my post and tell me what is my problem?

my post: http://www.coderanch.com/t/465377/Spring/StoredProcedure-outParameters-oracle

thanks very much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Iterarting ResultSet Conditionally
 
Similar Threads
HSQLDB Indexing Error?
String variables and Int variables
Help with sorting ArrayList using Comparator
Sorting a table of ArrayLists
Sorting ArrayList of MemberBean objects