High-performance Java | Persistence.pdf

Optimistic locking (via @Version) is great for low-contention data. However, for high-throughput systems where contention is likely, explicit pessimistic locking might be required to prevent deadlocks and ensure data integrity, though it comes at the cost of concurrency.

In a long-running transaction or a batch job, loading thousands of entities will swell the Persistence Context. The more entities it tracks, the slower the "dirty checking" mechanism becomes, and the more likely you are to run into an OutOfMemoryError. High-performance Java Persistence.pdf

The Fix: Use stateless sessions for batch processing, or periodically flush() and clear() the Persistence Context to detach entities that are no longer needed. Optimistic locking (via @Version ) is great for

Absolutely. With the rise of GraalVM Native Image, persistence has become tricky again. Reflection, proxies, and dynamic bytecode generation (Hibernate's specialty) often break native compilation. Query cache – Caches JPQL/HQL results

The latest editions of the High-performance Java Persistence.pdf cover:

  • Query cache – Caches JPQL/HQL results. Use only for static data.
  • When to avoid caching – Frequently updated data.
  • Hibernate will not create the perfect index for you automatically. Understanding that an index on (created_at) is useless for a query filtering by (status) is crucial. You must analyze your query execution plans (using EXPLAIN ANALYZE) to ensure your database is seeking, not scanning.

    Optimistic locking (via @Version) is great for low-contention data. However, for high-throughput systems where contention is likely, explicit pessimistic locking might be required to prevent deadlocks and ensure data integrity, though it comes at the cost of concurrency.

    In a long-running transaction or a batch job, loading thousands of entities will swell the Persistence Context. The more entities it tracks, the slower the "dirty checking" mechanism becomes, and the more likely you are to run into an OutOfMemoryError.

    The Fix: Use stateless sessions for batch processing, or periodically flush() and clear() the Persistence Context to detach entities that are no longer needed.

    Absolutely. With the rise of GraalVM Native Image, persistence has become tricky again. Reflection, proxies, and dynamic bytecode generation (Hibernate's specialty) often break native compilation.

    The latest editions of the High-performance Java Persistence.pdf cover:

  • Query cache – Caches JPQL/HQL results. Use only for static data.
  • When to avoid caching – Frequently updated data.
  • Hibernate will not create the perfect index for you automatically. Understanding that an index on (created_at) is useless for a query filtering by (status) is crucial. You must analyze your query execution plans (using EXPLAIN ANALYZE) to ensure your database is seeking, not scanning.

    Close (esc)

    Subscribe

    Subscribe to our email list for regular updates, news, and specials with ECU Master

    Age verification

    By clicking enter you are verifying that you are old enough to consume alcohol.

    Search

    Shopping Cart

    Your cart is currently empty.
    Shop now