SlideShare a Scribd company logo
1 of 16
Hibernate caching
       2012

     Barnabás Südy
barnabas.sudy@gmail.com
Structure
                                                          Three cache
1st level cache - Session cache
  Hibernate supported cache.
  Ensures the entities are returnd always on the same reference
  1/session (entitymanager) - Not thread safe

Query cache
  Not supported by default. (Ehcache)
  Stores the queries and their results.
  1/sessionfacory (entitymanagerfactory)

2nd level cache
  Not supported by default (Ehcache)
  Stores the entities (dehydrated - not as objects)
  1/sessionfactory (entitymanager)
Default behavior

    Hibernate does not run queries (at all)

    Query cache can store the
    (Query, List<PrimaryKey>) pairs.

    2nd level cache stores the entities.

Questions:

    What piece of data should be cached?

    Hibernate has to know which piece of
    data valid in the cache.
Read phenomena

    Phantom reads
    Other transaction modifies the data

    Non Repeatable reads
    Other transaction adds new data

    Dirty data
    Not committed data in the result.
Isolation levels

      Serializable
   --- Phantom reads ---
   Repeatable read
--- Non repeatable reads ---
   Committed read
      --- Dirty data ---
  Uncommitted read
2nd level cache

To optimise the performance Hibernate
 introduced the Cache strategies:

    Read only

    Read-Write

    NonStrict Read-Write

    Transactional
2nd level cache

To optimise the performance Hibernate
 introduced the Cache strategies:

    Read only

    Read-Write

    NonStrict Read-Write

    Transactional
Read only strategy

A read-only cache is good for data that
  needs to be read often but not
  modified.



    Simple

    Safe to use in a clustered environment.

    The data has to never ever modify.

    Best performance.
NonStrict Read-Write

Rarely need to modify data.
This is the case if two transactions are unlikely to try to update the
   same item simultaneously.


    No strict transaction isolation

    Ensure Session.close() or
    Session.disconnect() is called at the end
    of transaction. (except JTA)

    hibernate.transaction.manager_lookup_class to use in JTA environment.
Read-Write

Appropriate for an application which needs
 to update data regularly. (not exacly true)


    Do not use a if serializable isolation
    needed.

    Ensure Session.close() or
    Session.disconnect() is called at the end
    of transaction. (except JTA)

    hibernate.transaction.manager_lookup_class to use in JTA environment.
How is works - Read-only


    The modification is disabled.

    No 2nd level cache update needed.
How is works -
                    NonStrict Read-Write

    The entities are evicted from the 2nd
    level cache by their life timeout. Until the
    eviction they are in use.

    Repeatable reads problem is not solved.
    The queries are not forwarded to the
    database.
How it works - Read-write


    Transaction and entity timestamp.

    If transaction timestamp is older than the
    entity timestamp the entity has to be
    pulled out from the database.

    The responsibility is deflected to the
    database.
How it works - Read-write

Let's take a look our test code.
Good to know

    Be careful with query cache without 2nd level
    cache.

    Be careful 2nd level cache without query
    cache.

    Be careful query cache and read-write entity.

    And again: 2nd level cache is not queryable
    only findable.

    The first level cache keeps the entity
    references.
A little bit configuration....

    Persistence.xml

    Annotations

    Ehcache.xml

    Etc.

More Related Content

What's hot

Parallel XSLT Processing of Large XML Documents - XML Prague 2015
Parallel XSLT Processing of Large XML Documents - XML Prague 2015Parallel XSLT Processing of Large XML Documents - XML Prague 2015
Parallel XSLT Processing of Large XML Documents - XML Prague 2015Jakub Malý
 
BITS: Introduction to relational databases and MySQL - Schema design
BITS: Introduction to relational databases and MySQL - Schema designBITS: Introduction to relational databases and MySQL - Schema design
BITS: Introduction to relational databases and MySQL - Schema designBITS
 
Hadoop and Marklogic: Using the Genetic Algorithm to generate Source Code
Hadoop and Marklogic: Using the Genetic Algorithm to generate Source CodeHadoop and Marklogic: Using the Genetic Algorithm to generate Source Code
Hadoop and Marklogic: Using the Genetic Algorithm to generate Source Codejimfuller2009
 
Get mysql clusterrunning-windows
Get mysql clusterrunning-windowsGet mysql clusterrunning-windows
Get mysql clusterrunning-windowsJoeSg
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemEktaVaswani2
 
XSLT 3.0 - new features
XSLT 3.0 - new featuresXSLT 3.0 - new features
XSLT 3.0 - new featuresJakub Malý
 
Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232marangburu42
 

What's hot (10)

Parallel XSLT Processing of Large XML Documents - XML Prague 2015
Parallel XSLT Processing of Large XML Documents - XML Prague 2015Parallel XSLT Processing of Large XML Documents - XML Prague 2015
Parallel XSLT Processing of Large XML Documents - XML Prague 2015
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
BITS: Introduction to relational databases and MySQL - Schema design
BITS: Introduction to relational databases and MySQL - Schema designBITS: Introduction to relational databases and MySQL - Schema design
BITS: Introduction to relational databases and MySQL - Schema design
 
Hadoop and Marklogic: Using the Genetic Algorithm to generate Source Code
Hadoop and Marklogic: Using the Genetic Algorithm to generate Source CodeHadoop and Marklogic: Using the Genetic Algorithm to generate Source Code
Hadoop and Marklogic: Using the Genetic Algorithm to generate Source Code
 
Get mysql clusterrunning-windows
Get mysql clusterrunning-windowsGet mysql clusterrunning-windows
Get mysql clusterrunning-windows
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating System
 
XSLT 3.0 - new features
XSLT 3.0 - new featuresXSLT 3.0 - new features
XSLT 3.0 - new features
 
Cassandra
CassandraCassandra
Cassandra
 
Distributed deadlock
Distributed deadlockDistributed deadlock
Distributed deadlock
 
Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232
 

Similar to Hibernate caching

Advanced Hibernate Notes
Advanced Hibernate NotesAdvanced Hibernate Notes
Advanced Hibernate NotesKaniska Mandal
 
Hibernate complete Training
Hibernate complete TrainingHibernate complete Training
Hibernate complete Trainingsourabh aggarwal
 
10 Cache Implementation
10  Cache Implementation10  Cache Implementation
10 Cache ImplementationRanjan Kumar
 
Hibernate tutorial for beginners
Hibernate tutorial for beginnersHibernate tutorial for beginners
Hibernate tutorial for beginnersRahul Jain
 
02 Hibernate Introduction
02 Hibernate Introduction02 Hibernate Introduction
02 Hibernate IntroductionRanjan Kumar
 
Clustering In The Wild
Clustering In The WildClustering In The Wild
Clustering In The WildSergio Bossa
 
Advanced Hibernate V2
Advanced Hibernate V2Advanced Hibernate V2
Advanced Hibernate V2Haitham Raik
 
Hibernate Interview Questions and Answers
Hibernate Interview Questions and AnswersHibernate Interview Questions and Answers
Hibernate Interview Questions and AnswersAnuragMourya8
 
Synchronicity of a distributed account system
Synchronicity of a distributed account systemSynchronicity of a distributed account system
Synchronicity of a distributed account systemLuis Caldeira
 
Repository performance tuning
Repository performance tuningRepository performance tuning
Repository performance tuningJukka Zitting
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Examplekamal kotecha
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK toolsHaribabu Nandyal Padmanaban
 
Hibernate Session 1
Hibernate Session 1Hibernate Session 1
Hibernate Session 1b_kathir
 
Vmreport
VmreportVmreport
Vmreportmeru2ks
 

Similar to Hibernate caching (20)

Advanced Hibernate Notes
Advanced Hibernate NotesAdvanced Hibernate Notes
Advanced Hibernate Notes
 
Hibernate complete Training
Hibernate complete TrainingHibernate complete Training
Hibernate complete Training
 
10 Cache Implementation
10  Cache Implementation10  Cache Implementation
10 Cache Implementation
 
Hibernate tutorial for beginners
Hibernate tutorial for beginnersHibernate tutorial for beginners
Hibernate tutorial for beginners
 
02 Hibernate Introduction
02 Hibernate Introduction02 Hibernate Introduction
02 Hibernate Introduction
 
Clustering In The Wild
Clustering In The WildClustering In The Wild
Clustering In The Wild
 
Spring & hibernate
Spring & hibernateSpring & hibernate
Spring & hibernate
 
Hibernate Cache
Hibernate CacheHibernate Cache
Hibernate Cache
 
Advanced Hibernate V2
Advanced Hibernate V2Advanced Hibernate V2
Advanced Hibernate V2
 
Advance Features of Hibernate
Advance Features of HibernateAdvance Features of Hibernate
Advance Features of Hibernate
 
Kafka internals
Kafka internalsKafka internals
Kafka internals
 
Hibernate Interview Questions and Answers
Hibernate Interview Questions and AnswersHibernate Interview Questions and Answers
Hibernate Interview Questions and Answers
 
Synchronicity of a distributed account system
Synchronicity of a distributed account systemSynchronicity of a distributed account system
Synchronicity of a distributed account system
 
Repository performance tuning
Repository performance tuningRepository performance tuning
Repository performance tuning
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Example
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
 
Hibernate Session 1
Hibernate Session 1Hibernate Session 1
Hibernate Session 1
 
JahiaOne - Performance Tuning
JahiaOne - Performance TuningJahiaOne - Performance Tuning
JahiaOne - Performance Tuning
 
Vmreport
VmreportVmreport
Vmreport
 
05 Transactions
05 Transactions05 Transactions
05 Transactions
 

Recently uploaded

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Recently uploaded (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Hibernate caching

  • 1. Hibernate caching 2012 Barnabás Südy barnabas.sudy@gmail.com
  • 2. Structure Three cache 1st level cache - Session cache Hibernate supported cache. Ensures the entities are returnd always on the same reference 1/session (entitymanager) - Not thread safe Query cache Not supported by default. (Ehcache) Stores the queries and their results. 1/sessionfacory (entitymanagerfactory) 2nd level cache Not supported by default (Ehcache) Stores the entities (dehydrated - not as objects) 1/sessionfactory (entitymanager)
  • 3. Default behavior  Hibernate does not run queries (at all)  Query cache can store the (Query, List<PrimaryKey>) pairs.  2nd level cache stores the entities. Questions:  What piece of data should be cached?  Hibernate has to know which piece of data valid in the cache.
  • 4. Read phenomena  Phantom reads Other transaction modifies the data  Non Repeatable reads Other transaction adds new data  Dirty data Not committed data in the result.
  • 5. Isolation levels Serializable --- Phantom reads --- Repeatable read --- Non repeatable reads --- Committed read --- Dirty data --- Uncommitted read
  • 6. 2nd level cache To optimise the performance Hibernate introduced the Cache strategies:  Read only  Read-Write  NonStrict Read-Write  Transactional
  • 7. 2nd level cache To optimise the performance Hibernate introduced the Cache strategies:  Read only  Read-Write  NonStrict Read-Write  Transactional
  • 8. Read only strategy A read-only cache is good for data that needs to be read often but not modified.  Simple  Safe to use in a clustered environment.  The data has to never ever modify.  Best performance.
  • 9. NonStrict Read-Write Rarely need to modify data. This is the case if two transactions are unlikely to try to update the same item simultaneously.  No strict transaction isolation  Ensure Session.close() or Session.disconnect() is called at the end of transaction. (except JTA)  hibernate.transaction.manager_lookup_class to use in JTA environment.
  • 10. Read-Write Appropriate for an application which needs to update data regularly. (not exacly true)  Do not use a if serializable isolation needed.  Ensure Session.close() or Session.disconnect() is called at the end of transaction. (except JTA)  hibernate.transaction.manager_lookup_class to use in JTA environment.
  • 11. How is works - Read-only  The modification is disabled.  No 2nd level cache update needed.
  • 12. How is works - NonStrict Read-Write  The entities are evicted from the 2nd level cache by their life timeout. Until the eviction they are in use.  Repeatable reads problem is not solved. The queries are not forwarded to the database.
  • 13. How it works - Read-write  Transaction and entity timestamp.  If transaction timestamp is older than the entity timestamp the entity has to be pulled out from the database.  The responsibility is deflected to the database.
  • 14. How it works - Read-write Let's take a look our test code.
  • 15. Good to know  Be careful with query cache without 2nd level cache.  Be careful 2nd level cache without query cache.  Be careful query cache and read-write entity.  And again: 2nd level cache is not queryable only findable.  The first level cache keeps the entity references.
  • 16. A little bit configuration....  Persistence.xml  Annotations  Ehcache.xml  Etc.