I’ve found very interesting but not implemented method in some CoreDao Interface:
import org.apache.commons.lang3.tuple.Pair;
import javax.management.Query;
import java.util.List;
import java.util.function.Function;
public interface CoreDao<R> {
<R> void batchUpdateNamedQuery(String namedQueryName, List<R> updatedEntities, Function<Pair<R,Query>, Query> updater);
}
so, populate the implementation method body seems quite easy, after injecting EntityManager:
updatedEntities.stream().forEach({ ent ->
getEntityManager().createNamedQuery(namedQueryName);
params.apply(Pair.of(ent, query).executeUpdate();
})
but what functional programming example could be implemented as updater
? Any idea for Pair as the input to the function?