{"id":956,"date":"2012-02-02T16:39:00","date_gmt":"2012-02-02T16:39:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/hibernate-cache-levels-tutorial.html"},"modified":"2012-10-21T23:07:22","modified_gmt":"2012-10-21T23:07:22","slug":"hibernate-cache-levels-tutorial","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html","title":{"rendered":"Hibernate cache levels tutorial"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">One of the common problems of people that start using <strong>Hibernate <\/strong>is performance, if you don&#8217;t have much experience in <strong>Hibernate <\/strong>you will find how quickly your application becomes slow. If you enable sql traces, you would see how many queries are sent to database that can be avoided with little <strong>Hibernate <\/strong>knowledge. In current post I am going to explain how to use <strong>Hibernate Query Cache<\/strong> to avoid amount of traffic between your application and database.<\/p>\n<p><strong>Hibernate <\/strong>offers two caching levels:<\/p>\n<ul style=\"text-align: left\">\n<li>The first level cache is the session cache. Objects are cached within the current session and they are only alive until the session is closed.<\/li>\n<li>The second level cache exists as long as the session factory is alive. Keep in mind that in case of <strong>Hibernate<\/strong>, second level cache is not a tree of objects; object instances are not cached, instead it stores attribute values.<\/li>\n<\/ul>\n<p>After this brief introduction (so brief I know) about <strong>Hibernate <\/strong>cache, let&#8217;s see what is <strong>Query Cache<\/strong> and how is interrelated with second level cache.<\/p>\n<p><strong>Query Cache<\/strong> is responsible for caching the combination of query and values provided as parameters as key, and list of identifiers of objects returned by query execution as values. Note that using <strong>Query Cache<\/strong> requires a second level cache too because when query result is get from cache (that is a list of identifiers), <strong>Hibernate <\/strong>will load objects using cached identifiers from second level.<\/p>\n<p>To sum up, and as a conceptual schema, given next query: &#8220;<i>from Country where population &gt; :number<\/i>&#8220;, after first execution, <strong>Hibernate <\/strong>caches would contain next fictional values (note that number parameter is set to 1000):<\/p>\n<p><strong><u>L2 Cache<\/u><\/strong><br \/>\n[<br \/>\nid:1, {name=&#8217;Spain&#8217;, population=1000, &#8230;.}<br \/>\nid:2, {name=&#8217;Germany&#8217;, population=2000,&#8230;}<br \/>\n&#8230;.<br \/>\n]<br \/>\n<strong><u>QueryCache<\/u><\/strong><br \/>\n[{from Country where population &gt; :number, 1000}, {id:2}]<\/p>\n<p>So before start using <strong>Query Cache<\/strong>, we need to configure cache of second level.<br \/>\nFirst of all you must decide what cache provider you are going to use. For this example <strong>Ehcache<\/strong> is chosen, but refer to <strong>Hibernate <\/strong>documentation for complete list of all supported providers.<\/p>\n<p>To configure second level cache, set next <strong>Hibernate <\/strong>properties:<\/p>\n<p><i>hibernate.cache.provider_class = org.hibernate.cache.EhCacheProvider<\/i><br \/>\n<i>hibernate.cache.use_structured_entries = true<\/i><br \/>\n<i>hibernate.cache.use_second_level_cache = true<\/i><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>And if you are using annotation approach, annotate cachable entities with:<\/p>\n<p><i>@Cacheable<\/i><br \/>\n<i>@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)<\/i><\/p>\n<p>See that in this case cache concurrency strategy is <i>NONSTRICT_READ_WRITE<\/i>, but depending on cache provider, other strategies can be followed like <i>TRANSACTIONAL, READ_ONLY<\/i>, &#8230; take a look at cache section of <strong>Hibernate <\/strong>documentation to chose the one that fits better with your requirements.<\/p>\n<p>And finally add <strong>Ehcache <\/strong>dependencies:<\/p>\n<p><i>&lt;dependency&gt;<\/i><br \/>\n<i>&lt;groupId&gt;net.sf.ehcache&lt;\/groupId&gt;<\/i><br \/>\n<i>&lt;artifactId&gt;ehcache-core&lt;\/artifactId&gt;<\/i><br \/>\n<i>&lt;version&gt;2.5.0&lt;\/version&gt;<\/i><br \/>\n<i>&lt;\/dependency&gt;<\/i><br \/>\n<i>&lt;dependency&gt;<\/i><br \/>\n<i>&lt;groupId&gt;org.hibernate&lt;\/groupId&gt;<\/i><br \/>\n<i>&lt;artifactId&gt;hibernate-ehcache&lt;\/artifactId&gt;<\/i><br \/>\n<i>&lt;version&gt;3.6.0.Final&lt;\/version&gt;<\/i><br \/>\n<i>&lt;\/dependency&gt;<\/i><\/p>\n<p>Now second level cache is configured, but not <strong>query cache<\/strong>; anyway we are not far from our goal.<\/p>\n<p>Set <i>hibernate.cache.use_query_cache<\/i> property to <i>true<\/i>.<\/p>\n<p>And for each cachable query, we must call <i>setCachable <\/i>method during query creation:<\/p>\n<p><i>List&lt;Country&gt; list = session.createQuery(&#8220;from Country where population &gt; 1000&#8221;).setCacheable(true).list();<\/i><\/p>\n<p>To make example more practical I have uploaded a full <strong>query cache<\/strong> example with Spring Framework. To see clearly that <strong>query cache <\/strong>works I have used one public database hosted in <a href=\"http:\/\/ensembl.org\/\">ensembl.org<\/a>. The Ensembl project produces genome databases for vertebrates and other eukaryotic species, and makes this information freely available online. In this example query to <i>dna <\/i>table is cached.<\/p>\n<p>First of all <strong>Hibernate <\/strong>configuration:<\/p>\n<pre class=\"brush:java\">@Configuration\r\npublic class HibernateConfiguration {\r\n\r\n @Value(\"#{dataSource}\")\r\n private DataSource dataSource;\r\n\r\n @Bean\r\n public AnnotationSessionFactoryBean sessionFactoryBean() {\r\n  Properties props = new Properties();\r\n  props.put(\"hibernate.dialect\", EnhancedMySQL5HibernateDialect.class.getName());\r\n  props.put(\"hibernate.format_sql\", \"true\");\r\n  props.put(\"hibernate.show_sql\", \"true\");\r\n  props.put(\"hibernate.cache.provider_class\", \"org.hibernate.cache.EhCacheProvider\");\r\n  props.put(\"hibernate.cache.use_structured_entries\", \"true\");\r\n  props.put(\"hibernate.cache.use_query_cache\", \"true\");\r\n  props.put(\"hibernate.cache.use_second_level_cache\", \"true\");\r\n  props.put(\"hibernate.hbm2ddl.auto\", \"validate\");\r\n\r\n  AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean();\r\n  bean.setAnnotatedClasses(new Class[]{Dna.class});  \r\n  bean.setHibernateProperties(props);\r\n  bean.setDataSource(this.dataSource);\r\n  bean.setSchemaUpdate(true);\r\n  return bean;\r\n }\r\n\r\n}\r\n<\/pre>\n<p>It is a simple <strong>Hibernate <\/strong>configuration, using properties previously explained to configure second level cache.<\/p>\n<p><i>Entity <\/i>class is an entity that represents a sequence of <i>DNA<\/i>.<\/p>\n<pre class=\"brush:java\">@Entity(name=\"dna\")\r\n@Cacheable\r\n@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)\r\npublic class Dna {\r\n\r\n @Id\r\n private int seq_region_id;\r\n\r\n private String sequence;\r\n\r\n public int getSeq_region_id() {\r\n  return seq_region_id;\r\n }\r\n\r\n public void setSeq_region_id(int seq_region_id) {\r\n  this.seq_region_id = seq_region_id;\r\n }\r\n\r\n @Column\r\n public String getSequence() {\r\n  return sequence;\r\n }\r\n\r\n public void setSequence(String sequence) {\r\n  this.sequence = sequence;\r\n }\r\n\r\n}\r\n<\/pre>\n<p>To try <strong>query cache<\/strong>, we are going to implement one test where same query is executed multiple times.<\/p>\n<pre class=\"brush:java\">@Autowired\r\nprivate SessionFactory sessionFactory;\r\n\r\n@Test\r\npublic void fiftyFirstDnaSequenceShouldBeReturnedAndCached() throws Exception {\r\n for (int i = 0; i &lt; 5; i++) {\r\n  Session session = sessionFactory.openSession();\r\n  session.beginTransaction();\r\n\r\n  Time elapsedTime = new Time(\"findDna\"+i);\r\n\r\n  List&lt;Dna&gt; list = session.createQuery(\r\n    \"from dna\").setFirstResult(0).setMaxResults(50).setCacheable(true).list();\r\n\r\n\r\n  session.getTransaction().commit();\r\n  session.close();\r\n  elapsedTime.miliseconds(System.out);\r\n\r\n  for (Dna dna : list) {\r\n   System.out.println(dna);\r\n  }\r\n\r\n }\r\n}\r\n<\/pre>\n<p>We can see that we are returning first fifty <i>dna <\/i>sequences, and if you execute it, you will see that elapsed time between creation of query and commiting transaction is printed. As you can suppose only first iteration takes about 5 seconds to get all data, but the other ones only milliseconds.<\/p>\n<p>The foreach line just before query iteration will print object identifier through console. If you look carefully none of these identifiers will be repeated during all execution. This fact just goes to show you that <strong>Hibernate <\/strong>cache does not save objects but properties values, and the object itself is created each time.<\/p>\n<p>Last note, remember that <strong>Hibernate <\/strong>does not cache associations by default.<\/p>\n<p>Now after writing a query, think if it will contain static data and if it will be executed often. If it is the case, <strong>query cache<\/strong> is your friend to make <strong>Hibernate <\/strong>applications run faster.<\/p>\n<p><a href=\"https:\/\/github.com\/downloads\/maggandalf\/Blog-Examples\/hibernate-query-cache.zip\">Download Code<\/a><\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/www.lordofthejars.com\/2012\/01\/giuro-per-sempre-te-di-viver-morire-per.html\">Hibernate cache levels tutorial<\/a>&nbsp;from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a><span class=\"Apple-style-span\" style=\"font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif\"><span class=\"Apple-style-span\" style=\"font-size: 14px;line-height: 18px\"><strong>&nbsp;<\/strong><\/span><\/span>Alex Soto at the&nbsp;<a href=\"http:\/\/www.lordofthejars.com\/\">One Jar To Rule Them All<\/a>&nbsp;blog.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>One of the common problems of people that start using Hibernate is performance, if you don&#8217;t have much experience in Hibernate you will find how quickly your application becomes slow. If you enable sql traces, you would see how many queries are sent to database that can be avoided with little Hibernate knowledge. In current &hellip;<\/p>\n","protected":false},"author":119,"featured_media":153,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[285,31],"class_list":["post-956","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-cache","tag-jboss-hibernate"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Hibernate cache levels tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"One of the common problems of people that start using Hibernate is performance, if you don&#039;t have much experience in Hibernate you will find how quickly\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hibernate cache levels tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"One of the common problems of people that start using Hibernate is performance, if you don&#039;t have much experience in Hibernate you will find how quickly\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2012-02-02T16:39:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T23:07:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Alex Soto\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/alexsotob\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alex Soto\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/hibernate-cache-levels-tutorial.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/hibernate-cache-levels-tutorial.html\"},\"author\":{\"name\":\"Alex Soto\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/6566a1238c71f5d85ba5b5df5d2eac59\"},\"headline\":\"Hibernate cache levels tutorial\",\"datePublished\":\"2012-02-02T16:39:00+00:00\",\"dateModified\":\"2012-10-21T23:07:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/hibernate-cache-levels-tutorial.html\"},\"wordCount\":834,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/hibernate-cache-levels-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-hibernate-logo.jpg\",\"keywords\":[\"Cache\",\"JBoss Hibernate\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/hibernate-cache-levels-tutorial.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/hibernate-cache-levels-tutorial.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/hibernate-cache-levels-tutorial.html\",\"name\":\"Hibernate cache levels tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/hibernate-cache-levels-tutorial.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/hibernate-cache-levels-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-hibernate-logo.jpg\",\"datePublished\":\"2012-02-02T16:39:00+00:00\",\"dateModified\":\"2012-10-21T23:07:22+00:00\",\"description\":\"One of the common problems of people that start using Hibernate is performance, if you don't have much experience in Hibernate you will find how quickly\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/hibernate-cache-levels-tutorial.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/hibernate-cache-levels-tutorial.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/hibernate-cache-levels-tutorial.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-hibernate-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-hibernate-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/hibernate-cache-levels-tutorial.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Hibernate cache levels tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/6566a1238c71f5d85ba5b5df5d2eac59\",\"name\":\"Alex Soto\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cc3a211b790033d32fee33bb321b7bb6e2d381dab14531d3f2e8df9885bca7f9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cc3a211b790033d32fee33bb321b7bb6e2d381dab14531d3f2e8df9885bca7f9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cc3a211b790033d32fee33bb321b7bb6e2d381dab14531d3f2e8df9885bca7f9?s=96&d=mm&r=g\",\"caption\":\"Alex Soto\"},\"sameAs\":[\"http:\\\/\\\/www.lordofthejars.com\\\/\",\"https:\\\/\\\/x.com\\\/http:\\\/\\\/twitter.com\\\/alexsotob\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Alex-Soto\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hibernate cache levels tutorial - Java Code Geeks","description":"One of the common problems of people that start using Hibernate is performance, if you don't have much experience in Hibernate you will find how quickly","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html","og_locale":"en_US","og_type":"article","og_title":"Hibernate cache levels tutorial - Java Code Geeks","og_description":"One of the common problems of people that start using Hibernate is performance, if you don't have much experience in Hibernate you will find how quickly","og_url":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-02-02T16:39:00+00:00","article_modified_time":"2012-10-21T23:07:22+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","type":"image\/jpeg"}],"author":"Alex Soto","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/alexsotob","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Alex Soto","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html"},"author":{"name":"Alex Soto","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/6566a1238c71f5d85ba5b5df5d2eac59"},"headline":"Hibernate cache levels tutorial","datePublished":"2012-02-02T16:39:00+00:00","dateModified":"2012-10-21T23:07:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html"},"wordCount":834,"commentCount":2,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","keywords":["Cache","JBoss Hibernate"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html","url":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html","name":"Hibernate cache levels tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","datePublished":"2012-02-02T16:39:00+00:00","dateModified":"2012-10-21T23:07:22+00:00","description":"One of the common problems of people that start using Hibernate is performance, if you don't have much experience in Hibernate you will find how quickly","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/hibernate-cache-levels-tutorial.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Hibernate cache levels tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/6566a1238c71f5d85ba5b5df5d2eac59","name":"Alex Soto","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cc3a211b790033d32fee33bb321b7bb6e2d381dab14531d3f2e8df9885bca7f9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cc3a211b790033d32fee33bb321b7bb6e2d381dab14531d3f2e8df9885bca7f9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cc3a211b790033d32fee33bb321b7bb6e2d381dab14531d3f2e8df9885bca7f9?s=96&d=mm&r=g","caption":"Alex Soto"},"sameAs":["http:\/\/www.lordofthejars.com\/","https:\/\/x.com\/http:\/\/twitter.com\/alexsotob"],"url":"https:\/\/www.javacodegeeks.com\/author\/Alex-Soto"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=956"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/956\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/153"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}