Zum Inhalt springen

Early Materialization (ARCH4056)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key java.orm.early-materialization · Severity warning · Category orm

Filtering or sorting in memory after materializing the query to a list moves work that belongs in the database into the application. Push the predicate into the query.

List<Order> all = orderRepository.findAll();
List<Order> paid = all.stream()
.filter(o -> o.getStatus() == PAID) // whole table in memory
.collect(toList());
List<Order> paid = orderRepository.findByStatus(OrderStatus.PAID);

Push filtering/ordering/aggregation into the database via WHERE/ORDER BY, not in memory.