Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void increaseSalary() {
- List<Employee> employees = em.createQuery("SELECT e from Employee e WHERE e.department.id IN (1, 2, 4, 11)", Employee.class)
- .getResultList();
- em.getTransaction().begin();
- employees.forEach(e->em.detach(e));
- employees.forEach(e->e.setSalary(e.getSalary().multiply(BigDecimal.valueOf(1.12))));
- employees.forEach(e->em.merge(e));
- em.flush();
- em.getTransaction().commit();
- employees.forEach(e-> System.out.printf("%s %s ($%.2f)%n"
- ,e.getFirstName()
- ,e.getLastName()
- , (e.getSalary())));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement