Long id = new Long(request.getParameter("id"));
Connection connection = null;
PreparedStatement statement = null;
ResultSet resultSet = null;
Person person = null;
List<RoleRelationship> roleRelationships = null;
try {
connection = this.getConnection();
statement = connection.prepareStatement(SQL_QUERY_PERSON);
statement.setLong(1, id);
resultSet = statement.executeQuery();
if(resultSet.next()){
person = new Person();
person.setId(resultSet.getLong("ID"));
person.setFirstName(resultSet.getString("FIRST_NAME"));
person.setLastName(resultSet.getString("LAST_NAME"));
person.setAccountName(resultSet.getString("ACCOUNT_NAME"));
person.setPassword(resultSet.getString("PASSWORD"));
roleRelationships = new ArrayList<RoleRelationship>();
roleRelationships.add(generateRoleRelationship(resultSet));
while(resultSet.next()){
roleRelationships.add(generateRoleRelationship(resultSet));
}
person.setRoleRelationships(roleRelationships);
}
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("Maintain person(id:" + id + ")", e);
}