I've been trying to loop through my resultSet
but for some reason only the last object in my database is selected. The idea is that I already pulled my needed Section from my database and I now want to add objects to my secions array list.
e.g. I pulled a Section called "Guitar" with the SectionId 1
from my table Sections
and now want to add all objects from my table sectionmitschueler
where sectionid = 1
to section 1's arraylist.
resultSet = Persistence.executeQueryStatement(aConnection, "SELECT * "
+ "FROM sectionmitschueler");
while (resultSet.next()) {
for(SectionTO eineSectionTO : eventTO.getSections()) {
if(resultSet.getInt("sectionId") == eineSectionTO.getSectionId())
System.out.println(sectionTO.getSectionId());
sectionTO.getSchueler().add(resultSet.getInt("schuelerId"));
}
}
}