• Post Reply Bookmark Topic Watch Topic
  • New Topic

Auto generation of pk for beans?

 
Fiona Healy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

Just a quick question.
I was hard-coding ids for a report EJB. When i was retrieving all previously defined report names from the db in order to populate a list on the GUI, i used the following for-loop as follows:

for(int i = 1; ; i++)
{
Integer pk = new Integer(i);
ReportDefinitionRemote report;
report = home.findByPrimaryKey(pk)
}

//add report to a vector

Since i changed to using an auto generate method to generate pks using the code:
return new Integer((new Object()).hashCode())
its not returning any of the report names. Any other looping constructs i could use or a reason why this one is not working any more?
 
Arul Prasad
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i cant get your question correctly .....

what u need to get the Report from the DB through EJB.....

No Need of using the findByPrimaryKey() method for that

and it is a bad practise to give Remote Calls in the Loop...

according to the above code

for(int i = 1;;i++) (endless loop.....)

If u need the Collection of Records from the DB i.e if u need the report for the particular month or any other condition u can have the own finder methods which can return java.util.Collection.....

I didn't know whether i clear your doubt ..plz explain me more abt your needd

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!