-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: getting different coloumns data witha single method
PostPosted: Tue Aug 14, 2007 2:09 am 
Newbie

Joined: Thu Aug 09, 2007 9:37 pm
Posts: 5
hai all ,
iam having a problem.iam accessing a table with 20 columns
in my pojo class i have got 20 getters for 20 columns.
like
getColumn1();
getColumn2();
getColumn3();
.
.
.
.
getColumn20();
my application requirement is that i have to retrieve these column values
one by one in a loop.
in JDBC i have written like
for(int i=0;i<20;i++){
colValue=rs.getString("column"+i);
}

thank you all
sri ram

_________________
sriram


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 3:00 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
Use reflection to call the getColumnXX methods one at a time. Or create a collection of column data items in a separate table and iterate over it. Are your methods really called getColumn1 etc?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 6:13 am 
Newbie

Joined: Thu Aug 09, 2007 9:37 pm
Posts: 5
yah actually i have columns
site1
site2
..........site20
corresponding getters
i want to get all columns data in a for loop one by one.
i want equivalent to rs.getString("site"+i); in hibernate.

thanx

_________________
sriram


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 6:41 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
Why don't you model these properties as a collection then it would be trivial to iterate over them.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.