try {
rs = statement.executeQuery("select person_id,role from personrole");
while (rs.next()) {
for (int i = 0; i < projects.size(); i++) {
Project project = (Project)projects.get(i);
Role role = getRole(session, rs.getString("role"));
int personId = rs.getInt("person_id");
session.save(new RoleAssociation(project.getId(), personId, role.getId()));
// Person should have permission to read/edit their own profile
session.save(new Permission("system.person", 0, personId, "read%"));
session.save(new Permission("system.person", personId, personId, "edit%"));
}
}