<?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/"
		>
<channel>
	<title>Comments on: What&#8217;s wrong with Hibernate, #2</title>
	<atom:link href="http://biotext.org.uk/whats-wrong-with-hibernate-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://biotext.org.uk/whats-wrong-with-hibernate-2/</link>
	<description>Not a typewriter</description>
	<lastBuildDate>Tue, 07 Sep 2010 11:28:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Andrew</title>
		<link>http://biotext.org.uk/whats-wrong-with-hibernate-2/comment-page-1/#comment-39</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Sat, 03 Jan 2009 15:00:44 +0000</pubDate>
		<guid isPermaLink="false">http://biotext.org.uk/?p=5#comment-39</guid>
		<description>Panagiotis -- the analogy with sub-selects is misleading since a sub-select will just fail if the underlying DB can&#039;t do it. But the ln vs log vs log10 issue is a genuine *dialect* difference which I thought was the kind of thing Hibernate&#039;s idea of dialects was designed for. Please re-read the quote from Hibernate&#039;s web site at the top of the post.

Also I&#039;m not sure how a NullPointerException from the depths of HQL&#039;s query parser could be a sign of me &quot;doing it wrong&quot;, could you elaborate?

Likewise, Spencer, your debugging suggestions are only useful if the problem occurs *after* Hibernate has parsed the HQL and generated SQL. Not if it dies in an ugly manner before getting that far.</description>
		<content:encoded><![CDATA[<p>Panagiotis &#8212; the analogy with sub-selects is misleading since a sub-select will just fail if the underlying DB can&#8217;t do it. But the ln vs log vs log10 issue is a genuine *dialect* difference which I thought was the kind of thing Hibernate&#8217;s idea of dialects was designed for. Please re-read the quote from Hibernate&#8217;s web site at the top of the post.</p>
<p>Also I&#8217;m not sure how a NullPointerException from the depths of HQL&#8217;s query parser could be a sign of me &#8220;doing it wrong&#8221;, could you elaborate?</p>
<p>Likewise, Spencer, your debugging suggestions are only useful if the problem occurs *after* Hibernate has parsed the HQL and generated SQL. Not if it dies in an ugly manner before getting that far.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Panagiotis Xinos</title>
		<link>http://biotext.org.uk/whats-wrong-with-hibernate-2/comment-page-1/#comment-37</link>
		<dc:creator>Panagiotis Xinos</dc:creator>
		<pubDate>Mon, 29 Dec 2008 09:09:50 +0000</pubDate>
		<guid isPermaLink="false">http://biotext.org.uk/?p=5#comment-37</guid>
		<description>I don&#039;t think that there is a hibernate issue here... For me hibernate is an object / relational mapping plus persistence framework. 

HQL is actually a meta language similar to SQL just to smooth things up between your objects and the db.

Still in this case don&#039;t forget that you are not using hibernate as an intermediate between your objects and the database. You are using it as a standard jdbc connection without all the &quot;bells and whistles&quot;.

Things that HQL does not understand are passed AS IS in the database query. And there is an example of that in the HQL part of the hibernate manual (with an MS SQL query (14.14 section))

To wrap up... if your database couldn&#039;t handle sub-selects would you expect hibernate to handle them as well just because it does it on some other database?

Sorry m8... you are doing it wrong...</description>
		<content:encoded><![CDATA[<p>I don&#8217;t think that there is a hibernate issue here&#8230; For me hibernate is an object / relational mapping plus persistence framework. </p>
<p>HQL is actually a meta language similar to SQL just to smooth things up between your objects and the db.</p>
<p>Still in this case don&#8217;t forget that you are not using hibernate as an intermediate between your objects and the database. You are using it as a standard jdbc connection without all the &#8220;bells and whistles&#8221;.</p>
<p>Things that HQL does not understand are passed AS IS in the database query. And there is an example of that in the HQL part of the hibernate manual (with an MS SQL query (14.14 section))</p>
<p>To wrap up&#8230; if your database couldn&#8217;t handle sub-selects would you expect hibernate to handle them as well just because it does it on some other database?</p>
<p>Sorry m8&#8230; you are doing it wrong&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris Hofmans</title>
		<link>http://biotext.org.uk/whats-wrong-with-hibernate-2/comment-page-1/#comment-36</link>
		<dc:creator>Kris Hofmans</dc:creator>
		<pubDate>Mon, 29 Dec 2008 07:50:23 +0000</pubDate>
		<guid isPermaLink="false">http://biotext.org.uk/?p=5#comment-36</guid>
		<description>Your piece just makes me wonder why you don&#039;t have an integration testing enviroment where you have the exact same setup as production before you go live which you can run some tests against, but hey that could just be me :)</description>
		<content:encoded><![CDATA[<p>Your piece just makes me wonder why you don&#8217;t have an integration testing enviroment where you have the exact same setup as production before you go live which you can run some tests against, but hey that could just be me <img src='http://biotext.org.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Spencer Uresk</title>
		<link>http://biotext.org.uk/whats-wrong-with-hibernate-2/comment-page-1/#comment-35</link>
		<dc:creator>Spencer Uresk</dc:creator>
		<pubDate>Mon, 29 Dec 2008 03:25:21 +0000</pubDate>
		<guid isPermaLink="false">http://biotext.org.uk/?p=5#comment-35</guid>
		<description>I guess I&#039;m a bit confused as to what the problem is, other than you didn&#039;t familiarize yourself with HQL and possibly substitutions not working how you expect them to (I don&#039;t have any experience with them, so I don&#039;t know if what you are describing is a bug or if they just don&#039;t work that way).

The ability to use database-specific (and, yes, non-portable) functions is a very important feature and almost a requirement for many applications. You just have to make sure you know when you are doing something non-portable, which takes a small amount of reading upfront. The situation is the same when you start looking at the JPA side of things - sometimes you are using Hibernate-specific functions that are not going to work with other JPA implementations.

How would you resolve this in a better way? Not let people use database-specific functions?

I&#039;m also not sure how it is taking you so long to debug things. Hibernate will print out the queries it is emitting and you can easily turn on logging, so even if the error message you get doesn&#039;t always pinpoint the problem, it shouldn&#039;t take that long to figure out what is going on.

As a general rule, when I am trying to debug query issues, I almost always start by grabbing the sql that Hibernate is sending to the database and running it in SQL Developer or whatever database tool you use. I&#039;ve found that this normally gives you a pretty good idea of where the problem is.</description>
		<content:encoded><![CDATA[<p>I guess I&#8217;m a bit confused as to what the problem is, other than you didn&#8217;t familiarize yourself with HQL and possibly substitutions not working how you expect them to (I don&#8217;t have any experience with them, so I don&#8217;t know if what you are describing is a bug or if they just don&#8217;t work that way).</p>
<p>The ability to use database-specific (and, yes, non-portable) functions is a very important feature and almost a requirement for many applications. You just have to make sure you know when you are doing something non-portable, which takes a small amount of reading upfront. The situation is the same when you start looking at the JPA side of things &#8211; sometimes you are using Hibernate-specific functions that are not going to work with other JPA implementations.</p>
<p>How would you resolve this in a better way? Not let people use database-specific functions?</p>
<p>I&#8217;m also not sure how it is taking you so long to debug things. Hibernate will print out the queries it is emitting and you can easily turn on logging, so even if the error message you get doesn&#8217;t always pinpoint the problem, it shouldn&#8217;t take that long to figure out what is going on.</p>
<p>As a general rule, when I am trying to debug query issues, I almost always start by grabbing the sql that Hibernate is sending to the database and running it in SQL Developer or whatever database tool you use. I&#8217;ve found that this normally gives you a pretty good idea of where the problem is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JAlexoid</title>
		<link>http://biotext.org.uk/whats-wrong-with-hibernate-2/comment-page-1/#comment-34</link>
		<dc:creator>JAlexoid</dc:creator>
		<pubDate>Mon, 29 Dec 2008 03:14:33 +0000</pubDate>
		<guid isPermaLink="false">http://biotext.org.uk/?p=5#comment-34</guid>
		<description>Doesn&#039;t HQL support the JDBC escaped functions?

I think this link might help: http://forums.hibernate.org/viewtopic.php?p=2231852&amp;sid=28f5b868ecb5fdd6f59f2ee2743f48f4


For PostgreSQL JDBC supported: http://jdbc.postgresql.org/documentation/83/escaped-functions.html
Have NO idea about HSQLDB

Hope this helps in restoring some of Hibernate&#039;s credibility :)
Though I believe that ORM itself is broken.</description>
		<content:encoded><![CDATA[<p>Doesn&#8217;t HQL support the JDBC escaped functions?</p>
<p>I think this link might help: <a href="http://forums.hibernate.org/viewtopic.php?p=2231852&amp;sid=28f5b868ecb5fdd6f59f2ee2743f48f4" rel="nofollow">http://forums.hibernate.org/viewtopic.php?p=2231852&amp;sid=28f5b868ecb5fdd6f59f2ee2743f48f4</a></p>
<p>For PostgreSQL JDBC supported: <a href="http://jdbc.postgresql.org/documentation/83/escaped-functions.html" rel="nofollow">http://jdbc.postgresql.org/documentation/83/escaped-functions.html</a><br />
Have NO idea about HSQLDB</p>
<p>Hope this helps in restoring some of Hibernate&#8217;s credibility <img src='http://biotext.org.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Though I believe that ORM itself is broken.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stanasic</title>
		<link>http://biotext.org.uk/whats-wrong-with-hibernate-2/comment-page-1/#comment-29</link>
		<dc:creator>stanasic</dc:creator>
		<pubDate>Sun, 28 Dec 2008 17:24:23 +0000</pubDate>
		<guid isPermaLink="false">http://biotext.org.uk/?p=5#comment-29</guid>
		<description>From my point of view, throwing an exception like &quot;not supported in HQL&quot; makes Hibernate unusable in scenario when you exactly want to use specific, non-standard, DBMS function. I&#039;m not trying to downplay your problem, but it seems to me you&#039;re expecting Hibernate to know about all non-standard SQL functions and their implementations in each particular DBMS, which, in my opinion, is unrealistic.

You might want to take a look into Dialect implementations in Hibernate source. In order for Hibernate to solve the ln/log and similar issues, they would firstly have to define their own standard in HQL, say, log() in HQL stands for base-10 logarithm,  and ln() is natural logarithm. Then, all Dialect classes should be modified to reflect that - meaning that HSQL users would then have to call ln() instead of log() in their HQL queries, which would then make no sense to them, etc. I hope you&#039;re seeing where I&#039;m going with this example.

But, with the Dialect mechanism being completely open, you might want to try to roll your own, one that suits your precise needs. In particular, lines 133-134 in org.hibernate.dialect HSQLDialect could be changed to map log() and ln() into ln() and log10() respectively.

I am surprised about query substitution, though, since the documentation specifically states it can be used for renaming an SQL function. If you can make a minimal, standalone example that shows the bug, I suppose you can submit it to their JIRA.</description>
		<content:encoded><![CDATA[<p>From my point of view, throwing an exception like &#8220;not supported in HQL&#8221; makes Hibernate unusable in scenario when you exactly want to use specific, non-standard, DBMS function. I&#8217;m not trying to downplay your problem, but it seems to me you&#8217;re expecting Hibernate to know about all non-standard SQL functions and their implementations in each particular DBMS, which, in my opinion, is unrealistic.</p>
<p>You might want to take a look into Dialect implementations in Hibernate source. In order for Hibernate to solve the ln/log and similar issues, they would firstly have to define their own standard in HQL, say, log() in HQL stands for base-10 logarithm,  and ln() is natural logarithm. Then, all Dialect classes should be modified to reflect that &#8211; meaning that HSQL users would then have to call ln() instead of log() in their HQL queries, which would then make no sense to them, etc. I hope you&#8217;re seeing where I&#8217;m going with this example.</p>
<p>But, with the Dialect mechanism being completely open, you might want to try to roll your own, one that suits your precise needs. In particular, lines 133-134 in org.hibernate.dialect HSQLDialect could be changed to map log() and ln() into ln() and log10() respectively.</p>
<p>I am surprised about query substitution, though, since the documentation specifically states it can be used for renaming an SQL function. If you can make a minimal, standalone example that shows the bug, I suppose you can submit it to their JIRA.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://biotext.org.uk/whats-wrong-with-hibernate-2/comment-page-1/#comment-15</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Sat, 27 Dec 2008 12:32:29 +0000</pubDate>
		<guid isPermaLink="false">http://biotext.org.uk/?p=5#comment-15</guid>
		<description>Gavin, thanks for the feedback. Well for a start, it would be nice if you could work around it with the hibernate.query.substitutions property, but this does absolutely nothing:

http://forum.hibernate.org/viewtopic.php?t=993080

Leaving me wondering what this property is for.

Stanasic -- actually I&#039;d rather have an exception saying &quot;not supported in HQL, use native SQL instead&quot;, rather than end up with a situation where the results of a query can silently go from correct to incorrect when moving to a different DB.</description>
		<content:encoded><![CDATA[<p>Gavin, thanks for the feedback. Well for a start, it would be nice if you could work around it with the hibernate.query.substitutions property, but this does absolutely nothing:</p>
<p><a href="http://forum.hibernate.org/viewtopic.php?t=993080" rel="nofollow">http://forum.hibernate.org/viewtopic.php?t=993080</a></p>
<p>Leaving me wondering what this property is for.</p>
<p>Stanasic &#8212; actually I&#8217;d rather have an exception saying &#8220;not supported in HQL, use native SQL instead&#8221;, rather than end up with a situation where the results of a query can silently go from correct to incorrect when moving to a different DB.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gavin</title>
		<link>http://biotext.org.uk/whats-wrong-with-hibernate-2/comment-page-1/#comment-11</link>
		<dc:creator>Gavin</dc:creator>
		<pubDate>Sat, 27 Dec 2008 12:08:42 +0000</pubDate>
		<guid isPermaLink="false">http://biotext.org.uk/?p=5#comment-11</guid>
		<description>OK then, so what exactly *should* Hibernate do when you use a highly vendor-specific function that is not part of the SQL standard and is not listed in the HQL documentation as portable?

* throw an exception and prevent you from using it?
* log a useless and annoying warning?
* something else?

I&#039;m not exactly clear on what your proposed solution is.</description>
		<content:encoded><![CDATA[<p>OK then, so what exactly *should* Hibernate do when you use a highly vendor-specific function that is not part of the SQL standard and is not listed in the HQL documentation as portable?</p>
<p>* throw an exception and prevent you from using it?<br />
* log a useless and annoying warning?<br />
* something else?</p>
<p>I&#8217;m not exactly clear on what your proposed solution is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stanasic</title>
		<link>http://biotext.org.uk/whats-wrong-with-hibernate-2/comment-page-1/#comment-5</link>
		<dc:creator>stanasic</dc:creator>
		<pubDate>Fri, 26 Dec 2008 20:36:56 +0000</pubDate>
		<guid isPermaLink="false">http://biotext.org.uk/?p=5#comment-5</guid>
		<description>&gt; Hibernate not only fails to insulate you from dialect differences like these, it also introduces a false sense of safety by pretending that it does.

You are being very unfair here. HQL functions are generally being translated to their SQL counterparts, with respect to chosen dialect. Even when you limit query results, for example, Hibernate will issue a select top 100 on MySQL, and where rownum &lt; 100 on Oracle.

Now, obviously ln() and log() are not covered by respective HSQLDB and PostgreSQL dialect(s). But, the entire mechanism is completely open and adapting your own variant of dialect from Hibernate sources, if needed, is quite straight-forward. The majority of functions for majority of vendors is supported. Personally, I worked one application deployed on MySQL, MSSQL and Oracle, with no problems whatsoever.

Admittedly, Hibernate developers could have decided to disallow references to functions not explicitly covered by chosen dialect. But, on the other hand, that enables Hibernate users to use functions from DBMS version newer then Hibernate, by default. If MS would, say, add a MAGIC_NUMBER function into the next SQL Server release, you would be able to use it from HQL immediately.</description>
		<content:encoded><![CDATA[<p>&gt; Hibernate not only fails to insulate you from dialect differences like these, it also introduces a false sense of safety by pretending that it does.</p>
<p>You are being very unfair here. HQL functions are generally being translated to their SQL counterparts, with respect to chosen dialect. Even when you limit query results, for example, Hibernate will issue a select top 100 on MySQL, and where rownum &lt; 100 on Oracle.</p>
<p>Now, obviously ln() and log() are not covered by respective HSQLDB and PostgreSQL dialect(s). But, the entire mechanism is completely open and adapting your own variant of dialect from Hibernate sources, if needed, is quite straight-forward. The majority of functions for majority of vendors is supported. Personally, I worked one application deployed on MySQL, MSSQL and Oracle, with no problems whatsoever.</p>
<p>Admittedly, Hibernate developers could have decided to disallow references to functions not explicitly covered by chosen dialect. But, on the other hand, that enables Hibernate users to use functions from DBMS version newer then Hibernate, by default. If MS would, say, add a MAGIC_NUMBER function into the next SQL Server release, you would be able to use it from HQL immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: What&#8217;s wrong with Hibernate, #1 - biotext.org.uk</title>
		<link>http://biotext.org.uk/whats-wrong-with-hibernate-2/comment-page-1/#comment-3</link>
		<dc:creator>What&#8217;s wrong with Hibernate, #1 - biotext.org.uk</dc:creator>
		<pubDate>Wed, 24 Dec 2008 20:31:15 +0000</pubDate>
		<guid isPermaLink="false">http://biotext.org.uk/?p=5#comment-3</guid>
		<description>[...] Actually, you only get this error if you&#8217;re lucky &#8212; if you&#8217;re unlucky you get something even less helpful. [...]</description>
		<content:encoded><![CDATA[<p>[...] Actually, you only get this error if you&#8217;re lucky &#8212; if you&#8217;re unlucky you get something even less helpful. [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
