I'm a little confused as to why my map.getValue() only returns [Drafter] even though every test I've done using loops and list.get() return [Developer,Drafter]?
Here is my code with a better explanation of what is happening.
|
Code:
|
//resultSet contains 2 group names and both are sucessfully added to the groups list and displayed using MapEntry.getKey()
resultSet.beforeFirst();
while(resultSet.next()){
if(!groups.contains(rs.getString("GROUP_FULLNAME"))){
// System.out.println("Adding to groups: "+rs.getString("GROUP_FULLNAME"));
groups.add(resultSet.getString("GROUP_FULLNAME"));
}
} |
|
Code:
|
//roleNames is a result that contains all the roles when groupName = groups.get(xx)
for(int xx = 0; xx < groups.size(); xx++){
if(!roleNames.first()){
throw new Exception("role_name query failed!");
}
roleNames.beforeFirst();
rolesList.clear();
while(roleNames.next()){
System.out.println("Adding role: "+roleNames.getString("ROLE_NAME")+" to group: "+groups.get(xx));
rolesList.add(roleNames.getString("ROLE_NAME"));
}
//puts the key and value together in the map
System.out.println(groups.get(xx)+" : "+rolesList.size());
for(int i = 0; i<rolesList.size(); i++){
System.out.println(groups.get(xx)+" ...:..."+rolesList.get(i));
}
groupRoleInfoMap.put(groups.get(xx), rolesList);
} |
now the output for all that seems fine
|
Code:
|
Adding role: Developer to group: Corporate Engineering Technology
Adding role: Drafter to group: Corporate Engineering Technology
Corporate Engineering Technology : 2
Corporate Engineering Technology ...:...Developer
Corporate Engineering Technology ...:...Drafter
Adding role: Drafter to group: Rig Solutions.RS Mechanical.Mud Pumps
Rig Solutions.RS Mechanical.Mud Pumps : 1
Rig Solutions.RS Mechanical.Mud Pumps ...:...Drafter |
however when I use this code the output is different and doesn't show all roles
|
Code:
|
Set set = groupRoleInfoMap.entrySet();
Iterator i = set.iterator();
while(i.hasNext()){
Map.Entry me = (Map.Entry)i.next();
System.out.println(me.getKey() + " : " + me.getValue() );
} |
|
Code:
|
Corporate Engineering Technology : [Drafter]
Rig Solutions.RS Mechanical.Mud Pumps : [Drafter] |
I'm assuming all the data is there but some reassurance would be nice. Have I done something wrong within the iterator loop or what?