To reduce code duplication for every update of an attribute in JPA, I'd like to hand over a function pointer to doTransaction and invoke the function. How can I do that in Java 8?
public void modifySalary(Person person, float salary) {
doTransaction(person.setSalary(salary));
}
public void doTransaction(final Function<Void, Void> func) {
em.getTransaction().begin();
func.apply(null);
em.getTransaction().commit();
}