<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Hibernate Query (Lack Of) Caching</title>
	<atom:link href="http://twasink.net/2008/02/12/hibernate-query-lack-of-caching/feed/" rel="self" type="application/rss+xml" />
	<link>http://twasink.net/2008/02/12/hibernate-query-lack-of-caching/</link>
	<description>Robert&#039;s Rambling Ruminations Regarding Reality...</description>
	<lastBuildDate>Thu, 12 Apr 2012 16:31:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Bernard</title>
		<link>http://twasink.net/2008/02/12/hibernate-query-lack-of-caching/#comment-417</link>
		<dc:creator><![CDATA[Bernard]]></dc:creator>
		<pubDate>Tue, 27 Jan 2009 13:14:08 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=214#comment-417</guid>
		<description><![CDATA[No worries. Interesting discussion anyway. As I have an heavy loaded application that somehow relies on cache to improve performance, your article raised a big fear in me. It made reread the part in JPA with Hibernate on query cache (chapter 15). This confirmed that my implementation was ok.
I am a regular reader of your blog and enjoying it. I usually don&#039;t write comments but this time I thought your initial post needed clarification.
Cheers,
Bernard.]]></description>
		<content:encoded><![CDATA[<p>No worries. Interesting discussion anyway. As I have an heavy loaded application that somehow relies on cache to improve performance, your article raised a big fear in me. It made reread the part in JPA with Hibernate on query cache (chapter 15). This confirmed that my implementation was ok.<br />
I am a regular reader of your blog and enjoying it. I usually don&#8217;t write comments but this time I thought your initial post needed clarification.<br />
Cheers,<br />
Bernard.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert</title>
		<link>http://twasink.net/2008/02/12/hibernate-query-lack-of-caching/#comment-416</link>
		<dc:creator><![CDATA[Robert]]></dc:creator>
		<pubDate>Tue, 27 Jan 2009 10:31:06 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=214#comment-416</guid>
		<description><![CDATA[Granted, Bernard. I merely threw those out as options. Probably the only suggestion I made above that was serious was the option of making the queries themselves more tolerable of staleness - that is, to take something like the StaleTolerantQueryCache suggested above, and build it into Hibernate directly (including an option to defer to the caching system itself on how stale something can be).

For an alternative that is inline with the Hibernate philosophy, the event mechanism could be leveraged to allow vetoing of query cache evictions, even if the default Hibernate configuration never vetoed.

I own &quot;Hibernate In Action&quot;; I&#039;ve read &quot;Java Persistence with Hibernate&quot;. Neither really covers query caching properly, from memory (my books are at work; I&#039;m at home). According to the online table-of-contents, HIA gives 1 page, and JPwH gives 3-4.

In any case, this article isn&#039;t an attack on Hibernate, or even a set of suggestions of what Hibernate could do differently. I stopped trying to do that (shortly after I started trying) when a discussion with Gavin King resulted in him saying &quot;well, I&#039;ll get the (EJB 3 persistence) spec changed then&quot;. I use Hibernate, I recommend Hibernate, I think it&#039;s a good tool, and I even enjoy pushing its limits and trying to work more inline with how it wants to work. But it&#039;s not perfect, and when I come across limitations, I make a note here as an &lt;em&gt;aide-mémoire&lt;/em&gt;. Nor do I pick on just Hibernate - lots of tools that I use get this treatment.]]></description>
		<content:encoded><![CDATA[<p>Granted, Bernard. I merely threw those out as options. Probably the only suggestion I made above that was serious was the option of making the queries themselves more tolerable of staleness &#8211; that is, to take something like the StaleTolerantQueryCache suggested above, and build it into Hibernate directly (including an option to defer to the caching system itself on how stale something can be).</p>
<p>For an alternative that is inline with the Hibernate philosophy, the event mechanism could be leveraged to allow vetoing of query cache evictions, even if the default Hibernate configuration never vetoed.</p>
<p>I own &#8220;Hibernate In Action&#8221;; I&#8217;ve read &#8220;Java Persistence with Hibernate&#8221;. Neither really covers query caching properly, from memory (my books are at work; I&#8217;m at home). According to the online table-of-contents, HIA gives 1 page, and JPwH gives 3-4.</p>
<p>In any case, this article isn&#8217;t an attack on Hibernate, or even a set of suggestions of what Hibernate could do differently. I stopped trying to do that (shortly after I started trying) when a discussion with Gavin King resulted in him saying &#8220;well, I&#8217;ll get the (EJB 3 persistence) spec changed then&#8221;. I use Hibernate, I recommend Hibernate, I think it&#8217;s a good tool, and I even enjoy pushing its limits and trying to work more inline with how it wants to work. But it&#8217;s not perfect, and when I come across limitations, I make a note here as an <em>aide-mémoire</em>. Nor do I pick on just Hibernate &#8211; lots of tools that I use get this treatment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernard</title>
		<link>http://twasink.net/2008/02/12/hibernate-query-lack-of-caching/#comment-415</link>
		<dc:creator><![CDATA[Bernard]]></dc:creator>
		<pubDate>Tue, 27 Jan 2009 09:23:55 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=214#comment-415</guid>
		<description><![CDATA[Hibernate already monitors changes to entities. Your sentences &quot;it could monitor those to see if they still match&quot; and &quot;Updates to non-matching entities could be evaluated against cached queries to see if they should be inserted.&quot; would be VERY VERY difficult to implement and would drive hibernate to take over the responsibility of the database itself. If you know Hibernate, you should be aware that it never does that, it&#039;s not in its philosophy. 
It&#039;s true that Hibernate documentation, although good, is sometimes shallow on some aspects. In order to do efficient Hibernate development you really need a good Hibernate book on your side like &#039;Hibernate in action&#039; or &#039;Java Persistence with Hibernate&#039;.]]></description>
		<content:encoded><![CDATA[<p>Hibernate already monitors changes to entities. Your sentences &#8220;it could monitor those to see if they still match&#8221; and &#8220;Updates to non-matching entities could be evaluated against cached queries to see if they should be inserted.&#8221; would be VERY VERY difficult to implement and would drive hibernate to take over the responsibility of the database itself. If you know Hibernate, you should be aware that it never does that, it&#8217;s not in its philosophy.<br />
It&#8217;s true that Hibernate documentation, although good, is sometimes shallow on some aspects. In order to do efficient Hibernate development you really need a good Hibernate book on your side like &#8216;Hibernate in action&#8217; or &#8216;Java Persistence with Hibernate&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert</title>
		<link>http://twasink.net/2008/02/12/hibernate-query-lack-of-caching/#comment-414</link>
		<dc:creator><![CDATA[Robert]]></dc:creator>
		<pubDate>Sat, 24 Jan 2009 01:11:20 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=214#comment-414</guid>
		<description><![CDATA[Bernard, how does Hibernate know if an update in the database occurs? It can&#039;t. Therefore, for entity caching, Hibernate provides numerous cache modes for entities, where as a developer we can choose to trade off performance vs. staleness. Query caches could have the same. They don&#039;t.

So one option would be to configure stale-tolerant vs. non-stale tolerant directly into the query cache.

Another alternative would be to monitor changes to entities. Hibernate knows which entities were returned in a query; it could monitor those to see if they still match. Updates to non-matching entities could be evaluated against cached queries to see if they should be inserted. (Both as configurable options; the former is more efficient than the latter)

So there are a number of options.

The Hibernate documentation also provides detailed breakdowns of how the entity caches works. There&#039;s just a brief description of how to configure query and collection caching, but with no explanation of the implications (as mentioned above).]]></description>
		<content:encoded><![CDATA[<p>Bernard, how does Hibernate know if an update in the database occurs? It can&#8217;t. Therefore, for entity caching, Hibernate provides numerous cache modes for entities, where as a developer we can choose to trade off performance vs. staleness. Query caches could have the same. They don&#8217;t.</p>
<p>So one option would be to configure stale-tolerant vs. non-stale tolerant directly into the query cache.</p>
<p>Another alternative would be to monitor changes to entities. Hibernate knows which entities were returned in a query; it could monitor those to see if they still match. Updates to non-matching entities could be evaluated against cached queries to see if they should be inserted. (Both as configurable options; the former is more efficient than the latter)</p>
<p>So there are a number of options.</p>
<p>The Hibernate documentation also provides detailed breakdowns of how the entity caches works. There&#8217;s just a brief description of how to configure query and collection caching, but with no explanation of the implications (as mentioned above).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernard</title>
		<link>http://twasink.net/2008/02/12/hibernate-query-lack-of-caching/#comment-413</link>
		<dc:creator><![CDATA[Bernard]]></dc:creator>
		<pubDate>Fri, 23 Jan 2009 10:14:55 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=214#comment-413</guid>
		<description><![CDATA[This kind of behavior from Hibernate makes perfect sense to me. How would Hibernate know when an update occurs on one entity that it doesn&#039;t affect the cached query results. The implementation in Hibernate is generic and is designed to work correctly in all type of applications. Like you wrote in the conclusion of your article, if you need a different behavior you need to implement your own cache mechanism on top of Hibernate.]]></description>
		<content:encoded><![CDATA[<p>This kind of behavior from Hibernate makes perfect sense to me. How would Hibernate know when an update occurs on one entity that it doesn&#8217;t affect the cached query results. The implementation in Hibernate is generic and is designed to work correctly in all type of applications. Like you wrote in the conclusion of your article, if you need a different behavior you need to implement your own cache mechanism on top of Hibernate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonah S</title>
		<link>http://twasink.net/2008/02/12/hibernate-query-lack-of-caching/#comment-412</link>
		<dc:creator><![CDATA[Jonah S]]></dc:creator>
		<pubDate>Fri, 22 Feb 2008 10:37:52 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=214#comment-412</guid>
		<description><![CDATA[Try implementing a StaleTolerantQueryCache as described here: http://www.hibernate.org/213.html
]]></description>
		<content:encoded><![CDATA[<p>Try implementing a StaleTolerantQueryCache as described here: <a href="http://www.hibernate.org/213.html" rel="nofollow">http://www.hibernate.org/213.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bruno da Silva</title>
		<link>http://twasink.net/2008/02/12/hibernate-query-lack-of-caching/#comment-411</link>
		<dc:creator><![CDATA[Bruno da Silva]]></dc:creator>
		<pubDate>Sat, 16 Feb 2008 05:44:17 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=214#comment-411</guid>
		<description><![CDATA[I would suggest you to remove cache from your collections and relations and put all lazy true and test because if your cache is getting evicted the load/fetch process is much faster..much faster in collection without cache defined.

or i didn&#039;t test yet ... put the cache read-only and implement by your self the eviction policy .. i never tested a cache read-only on a modifiable entity yet..



]]></description>
		<content:encoded><![CDATA[<p>I would suggest you to remove cache from your collections and relations and put all lazy true and test because if your cache is getting evicted the load/fetch process is much faster..much faster in collection without cache defined.</p>
<p>or i didn&#8217;t test yet &#8230; put the cache read-only and implement by your self the eviction policy .. i never tested a cache read-only on a modifiable entity yet..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Serodio</title>
		<link>http://twasink.net/2008/02/12/hibernate-query-lack-of-caching/#comment-410</link>
		<dc:creator><![CDATA[Daniel Serodio]]></dc:creator>
		<pubDate>Fri, 15 Feb 2008 22:50:08 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=214#comment-410</guid>
		<description><![CDATA[I noticed that Hibernate&#039;s cache is much less effective than I thought, but I hadn&#039;t dug deep enough to come to these conclusions. Isn&#039;t there a way to make Hibernate&#039;s cache more effective instead of creating a separate cache layer above it?
]]></description>
		<content:encoded><![CDATA[<p>I noticed that Hibernate&#8217;s cache is much less effective than I thought, but I hadn&#8217;t dug deep enough to come to these conclusions. Isn&#8217;t there a way to make Hibernate&#8217;s cache more effective instead of creating a separate cache layer above it?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

