speedment / jpa-streamer

JPAstreamer is a lightweight library for expressing JPA queries as Java Streams
GNU Lesser General Public License v2.1
345 stars 35 forks source link

Allow optimized pipelines för database writes #281

Open julgus opened 2 years ago

julgus commented 2 years ago

Currently, JPAStreamer is unable to optimize a pipeline that persists DB entities. The example below generates an update query for each Film entity that passes the filter. Optimally, JPAStreamer would render this to a single HQL UPDATE.

    @Transactional
    public void updateDescription(String desc, short length) {
        jpaStreamer.stream(Film.class)
                .filter(Film$.length.greaterThan(length))
                .forEach(f -> {
                    f.setDescription(desc);
                    persist(f);
                }); 
    }