Question 18 of 72 from exam 1Z0-900: Java EE 7 Application Developer

Question 18 of 72 from exam 1Z0-900: Java EE 7 Application Developer

Question

Given the code fragments:

‘@Stateless
public class HRService {
@PersistenceContext(unitName="HRApp-PU")
private Employee findEmployee(String badgeld) {
return entityManager.find(Employee.class, badgeld);
}
public void updateEmployee(Employee emp) {
//add code here
}
}

@WebServiet(name="HR", urlPatterns={"/hr"})
public class HRServlet extends HttpServlet {
EB
private HRService hrService;
public void doGet(HttpServletRequest req, HttpServletResponse res)

throws ServletException, IOException {

String badgeld = req.getParameter("badge");
String name = req.getParameter(""name');
Employee emp = hrService.findEmployee(badgeld);
emp.setName(name);
hrService.updateEmployee(emp);

What code should you add to the body of the updateEmployee method in order to save pending changes to the database?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

B.