<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ibananti&#039;s blog &#187; db</title>
	<atom:link href="http://blog.boyandi.net/category/db/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.boyandi.net</link>
	<description>notes about ui, web development, visualization. links, tips and tricks</description>
	<lastBuildDate>Tue, 29 Jun 2010 15:11:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Problems with Hibernate</title>
		<link>http://blog.boyandi.net/2009/02/17/problems-with-hibernate/</link>
		<comments>http://blog.boyandi.net/2009/02/17/problems-with-hibernate/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 14:17:06 +0000</pubDate>
		<dc:creator>Ilya Boyandin</dc:creator>
				<category><![CDATA[db]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.boyandi.net/?p=15</guid>
		<description><![CDATA[After 8 months of development of a new project with extensive use of Hibernate I can now tell about my experiences with it. In general, Hibernate is a very useful tool. It saves a lot of time, because you don&#8217;t have to write SQL queries. If you make changes, you usually don&#8217;t have to rewrite [...]]]></description>
			<content:encoded><![CDATA[<p>After 8 months of development of a new project with extensive use of Hibernate I can now tell about my experiences with it. In general, Hibernate is a very useful tool. It saves a lot of time, because you don&#8217;t have to write SQL queries. If you make changes, you usually don&#8217;t have to rewrite queries, because there are only a few of them. The configuration using annotations is simple and powerful (and I personally prefer it to writing mappings in XML). Hibernate is able to generate database tables from mapped classes automatically and even update them as you add new fields to a class. Hibernate caching facilities are very useful. Finally, Hibernate allows to develop database vendor indepentent applications.</p>
<p>But there are few problems which I experienced:</p>
<ol>
<li>The most frustrating is in fact <a href="http://www.hibernate.org/hib_docs/reference/en/html/performance.html#performance-fetching-proxies">described in the Hibernate docs</a>. An object returned by session.load() isn&#8217;t necessarily an object of the expected class:

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">Cat cat <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Cat<span style="color: #009900;">&#41;</span> session.<span style="color: #006633;">load</span><span style="color: #009900;">&#40;</span>Cat.<span style="color: #000000; font-weight: bold;">class</span>, id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// instantiate a proxy (does not hit the db)</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>cat.<span style="color: #006633;">isDomesticCat</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>                  <span style="color: #666666; font-style: italic;">// hit the db to initialize the proxy</span>
    DomesticCat dc <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>DomesticCat<span style="color: #009900;">&#41;</span> cat<span style="color: #339933;">;</span>       <span style="color: #666666; font-style: italic;">// Error!</span>
    ....
<span style="color: #009900;">&#125;</span></pre></div></div>

</li>
<li>No inheritance mapping for value objects: here is the <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-1152">JIRA issue</a> that never gets fixed, and a <a href="http://priyanshugoyal.wordpress.com/2007/11/15/hibernate-component-value-object-inheritance-mapping/">workaround</a>.</li>
<li>The strong <a href="http://www.hibernate.org/hib_docs/annotations/reference/en/html/entity.html#entity-mapping-association-collections">suggestion in the Hibernate documentation</a> to use a join table for every unidirectional one-to-many association (in the section 2.2.5.3.2.2. &#8220;Unidirectional&#8221;). Another suggestion <a href="http://forum.hibernate.org/viewtopic.php?t=954178&amp;highlight=unidirectional+null+foriegn+foreign+key">is discussed here</a>.</li>
<li>2nd level caching should be used with caution: after deleting an object the stale version can still stay in cache which can lead to an ObjectNotFoundException. I found no other solution except disabling the 2nd level cache for the class.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.boyandi.net/2009/02/17/problems-with-hibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL parameters and query optimization</title>
		<link>http://blog.boyandi.net/2007/09/03/6/</link>
		<comments>http://blog.boyandi.net/2007/09/03/6/#comments</comments>
		<pubDate>Mon, 03 Sep 2007 07:23:37 +0000</pubDate>
		<dc:creator>Ilya Boyandin</dc:creator>
				<category><![CDATA[db]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.boyandi.net/?p=6</guid>
		<description><![CDATA[Few days ago we found out that passing in SQL parameters to a PreparedStatement can affect query optimization when we ran into a problem querying the database from our web app. We constantly got the following error from SQL Server: Adding a value to a &#8216;datetime&#8217; column caused overflow. In the WHERE clause of the [...]]]></description>
			<content:encoded><![CDATA[<p>Few days ago we found out that passing in SQL parameters to a PreparedStatement can affect query optimization when we ran into a problem querying the database from our web app. We constantly got the following error from SQL Server: <em>Adding a value to a &#8216;datetime&#8217; column caused overflow</em>. In the WHERE clause of the query we had something like DATEADD(month, 2, exam_date) and it went wrong, because there was an invalid exam_date entry in the database table (something like 0095-01-10).</p>
<p>The funny thing is that when we tried to run the very same query in Microsoft Query Analyzer it worked without an error. Then I wrote a short test that queried the database directly using PreparedStatement without Spring and iBatis to localize the problem and found out that when I passed parameters to it the error came, when I put the parameter values into the query itself it didn&#8217;t. So it seems that <em>passing the parameters affected the order in which the conditions in the WHERE clause were evaluated</em>: without the parameters another condition was evaluated first so that the errorneous date entry  was filtered out before coming to the condition which used DATEADD.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.boyandi.net/2007/09/03/6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
