Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get particular column from table  RSS feed

 
deepa sundaram
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am having a method called findBy(String )which returns only one row,I am getting that in Collection and iterating that, I want a particular column from that row say, and I have to pass that column value as a parameter to another method.

do anyone can tell me how to get the column from the collection object??

thanks in advance,

dkarun
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37230
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepa,
What you described is the simplest way to do it in a way that is supported by all app servers. Some app servers will let you do a SQL query from within a finder.
 
deepa sundaram
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

Here is the method where I am passing employeeid as parameter to the finder method(findBYSAPEmployeeID) its returning a single row and I am getting that in header object.Using that I have to get ID column from the table which is a primarykey.(like header.getID()) but the thing is, ID is a primary key and I am not having the getter setters for that,

so I am doing headers.getPrimaryKey(),like below.
Long id=(Long)header.getPrimaryKey()
and passing this ID as a parameter to another method..

I want to know what I am doing is right?

Thanks
deepa

Paf_headerLocalHome headerHome =(Paf_headerLocalHome) lookup(Constants.REFERENCE_PAF_HEADER);
Paf_headerLocal header = null;
Paf_sequenceLocal seq=null;

try{
header = headerHome.findBySAPEmployeeID(employeeID);
Long id=(Long)header.getPrimaryKey() ;

return getTermPaf(id);
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37230
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. What you are doing is correct and I don't see anyway to simplify it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!