Skip to content

3.0.2

Compare
Choose a tag to compare
@julgus julgus released this 19 Jun 14:04
· 71 commits to master since this release

Major changes

JPAStreamer now requires JDK 11+

JPAStreamer has been migrated to JDK 11, aligning with the compatibility requirements of popular JPA providers such as Hibernate and Spring Boot. The transition to JDK 11 enables us to leverage the benefits of Java Platform Module System (JPMS), facilitating improved modularity, encapsulation, performance, and security.

No internal caching of StreamSuppliers

Previously, JPAStreamer used to cache StreamSuppliers and their underlying Entity Managers. However, this caching sometimes resulted in connection leaks, e.g. when using Spring Boot and Hikari (refer to issue #147 for more information).

To address this issue, JPAStreamer no longer caches any StreamSuppliers and their associated Entity Managers. Instead, it allows you to take control over the lifecycle management of the underlying StreamSupplier yourself. This provides you with more flexibility and enables you to handle the lifecycle of the underlying resources according to your specific requirements.

In the following example, the same stream source is used twice, potentially saving some resources by reusing the underlying Entity Manager for both queries (the benefit is naturally greater with more reuses):

final JPAStreamer jpaStreamer = JPAStreamer.of("sakila"); 

try (final StreamSupplier<Film> supplier = jpaStreamer.createStreamSupplier(Film.class)) {

        List<Film> short = supplier.stream()
               .filter(Film$.length.lessThan(60))
               .sorted(Film$.length) 
               .collect(Collectors.toList()); 
        
        List<Film> longFilms = supplier.stream()
               .filter(Film$.length.greaterThanOrEqual(61))
               .sorted(Film$.length) 
               .collect(Collectors.toList()); 

}  // closes the StreamSupplier and the underlying Entity Manager 

With the removal of the cache feature, we have made the decision to deprecate the JPAStreamer.resetStreamer(Class<?>... entityClasses) method. This method was previously used to remove a StreamSupplier from the cache.

Complete changelog

#341 resetStreamer() does not close the underlying Entity Manager
#332 Fix Antora pipeline
#331 Convert codebase to Java 11 baseline
#274 String Index Out of Bounds Error when compiling project with fieldgenerator
#165 JPA Streamer not working with MapStruct
#147 Potential connection leak
#94 docs: Custom theme is not rendered correctly in the Safari browser
#83 Add a "latest" version in Antora
#48 fieldgenerator-standard: Enable JavaDoc generation under the module system
#19 fieldgenerator fails under client running with JPMS