Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java Iterate Problem

Status
Not open for further replies.

luckydexte

Programmer
Apr 26, 2001
84
US
Hello all,

I am running into a problem that I cannot seem to solve. I have an ArrayList of a object called roads and the iterate function is not working the way it should (or at least the way I think it should). Here is the code:

ArrayList roads = new RoadFunctions().getRoadMatching(roadNumber);

Iterator i = roadCondList.iterator();
while(i.hasNext()) {
RoadCond rc = (RoadCond) i.next();
System.err.println(rc.getSegId_());
}

The output is:
56683
56683
56683
56683
56683

However, there are five different Seg ID's in the table that I am pulling from. The SQL generated is as follows and when I run it from the command line I get the correct result.

select
roadcond0_.ROAD_NO,
roadcond0_.NUM_RATING,
roadcond0_.SEGMENT_ID,
roadcond0_.RESULT_DATE,
roadcond0_.STATUS,
roadcond0_.PROGRAM,
roadcond0_.FY
from
ROADCOND
where
ROAD_NO=6444

Any ideas what I am doing wrong?

Thanks,

Brandon
 
One note, the line Iterator i = roadCondList.iterator(); should be Iterator i = roads.iterator();. Bad copy and paste on my part.
 
Doh, I got it. It was a hibernate mapping issue with the primary key. Sorry to bother anyone if they looked at this.

Thanks,

Brandon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top