<?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>TechieDan &#187; hibernate</title>
	<atom:link href="http://techiedan.com/tag/hibernate/feed/" rel="self" type="application/rss+xml" />
	<link>http://techiedan.com</link>
	<description>Your Search for The Tech Stuffs</description>
	<lastBuildDate>Tue, 22 May 2012 08:10:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Using DetachedCriteria get Result with another Table</title>
		<link>http://techiedan.com/2010/06/01/using-detachedcriteria-get-result-with-another-table/</link>
		<comments>http://techiedan.com/2010/06/01/using-detachedcriteria-get-result-with-another-table/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 12:02:37 +0000</pubDate>
		<dc:creator>techieDan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[criteria]]></category>
		<category><![CDATA[detachedcriteria]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[hql]]></category>

		<guid isPermaLink="false">http://techiedan.com/?p=849</guid>
		<description><![CDATA[How to use Hibernate's DetachedCriteria to get result by using Join for a class. As of newest Hibernate, the type Expression is deprecated and that's where Restrictions come into place. What's the difference then by using HQL and Criterias?]]></description>
			<content:encoded><![CDATA[<p>How to use <strong>Hibernate&#8217;s DetachedCriteria</strong> to get result by using Join for a class. As of newest Hibernate, the type <strong>Expression</strong> is deprecated and that&#8217;s where <strong>Restrictions</strong> come into place.</p>
<p><img class="alignnone size-full wp-image-850" title="Hibernate Title" src="http://techiedan.com/wp-content/uploads/2010/06/hibernate.jpg" alt="Hibernate Title" width="455" height="145" /></p>
<p>Let&#8217;s say a HQL query like this.</p>
<blockquote><p><em>List list = hibernateTemplate.getSessionFactory().getCurrentSession().createQuery(&#8220;from Function fn where fn.createdByStaff=loginStaff and fn.prospect.processTypeId in (&#8217;1&#8242;,&#8217;4&#8242;,&#8217;5&#8242;)&#8221;).list();</em></p></blockquote>
<p>Now let&#8217;s try using DetachedCriteria to solve this.</p>
<blockquote><p><em>DetachedCriteria criteria = DetachedCriteria.forClass(Function.class).add(Restrictions.eq(&#8220;createdByStaff&#8221;, loginStaff)).createCriteria(&#8220;prospect&#8221;, &#8220;prospect&#8221;).add(Restrictions.in(&#8220;prospect.processTypeId&#8221;, processTypes));</em></p></blockquote>
<p>Then let&#8217;s say I need to set max size to 100 or any other amount.</p>
<blockquote><p><em>List list = hibernateTemplate.findByCriteria(criteria,0,100);</em></p></blockquote>
<p>It&#8217;s done. Simple to use. One reason to use a max size is so that one doesn&#8217;t fetch the whole table and result in Java Heapspace Out of Memory issue.</p>
<p>What&#8217;s the <strong>difference then by using HQL and Criterias</strong>?</p>
<blockquote><p><em>Criteria respects the laziness settings in your mappings and guarantees that what you want loaded is loaded. This means one Criteria query might result in several SQL immediate SELECT statements to fetch the subgraph with all non-lazy mapped associations and collections. If you want to change the &#8220;how&#8221; and even the &#8220;what&#8221;, use setFetchMode() to enable or disable outer join fetching for a particular collection or association. <strong>Criteria queries also completely respect the fetching strategy (join vs select vs subselect).</strong></em></p>
<p><em>HQL respects the laziness settings in your mappings and guarantees that what you want loaded is loaded. This means one HQL query might result in several SQL immediate SELECT statements to fetch the subgraph with all non-lazy mapped associations and collections. If you want to change the &#8220;how&#8221; and even the &#8220;what&#8221;, use LEFT JOIN FETCH to enable outer-join fetching for a particular collection or nullable many-to-one or one-to-one association, or JOIN FETCH to enable inner join fetching for a non-nullable many-to-one or one-to-one association. <strong>HQL queries do not respect any fetch=&#8221;join&#8221; defined in the mapping document.</strong></em></p>
<p><em>Source from <a title="HQL and Criteria Differences" href="http://www.hibernate.org/315.html" target="_blank">http://www.hibernate.org/315.html</a></em></p></blockquote>
<p>Now the last line of each paragraph tells the main difference of the HQL and Criteria search of the Hibernate.</p>
]]></content:encoded>
			<wfw:commentRss>http://techiedan.com/2010/06/01/using-detachedcriteria-get-result-with-another-table/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hibernate Error : exception setting property value</title>
		<link>http://techiedan.com/2009/12/17/hibernate-error-exception-setting-property-value/</link>
		<comments>http://techiedan.com/2009/12/17/hibernate-error-exception-setting-property-value/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 07:25:38 +0000</pubDate>
		<dc:creator>techieDan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://techiedan.com/?p=709</guid>
		<description><![CDATA[<p>Been playing around with <a title="Hibernate Mapping Site" href="http://www.hibernate.org" target="_blank">Hibernate</a> and mapping classes with Java. A reason why Hibernate is useful is so to facilitate users to stop writing pure SQL for queries and reduce code redundancy. A slight note, Hibernate also works well with the <strong>.NET platform</strong>.</p>
<p></p>
<p>Though there was this error which TechieDan experienced</p>
<p><em>org.springframework.orm.hibernate3.HibernateSystemException: [...]]]></description>
			<content:encoded><![CDATA[<p>Been playing around with <a title="Hibernate Mapping Site" href="http://www.hibernate.org" target="_blank">Hibernate</a> and mapping classes with Java. A reason why Hibernate is useful is so to facilitate users to stop writing pure SQL for queries and reduce code redundancy. A slight note, Hibernate also works well with the <strong>.NET platform</strong>.</p>
<p><img class="alignnone size-full wp-image-712" title="Hibernate Mapping Error" src="http://techiedan.com/wp-content/uploads/2009/12/error-hibernate.jpg" alt="Hibernate Mapping Error" width="305" height="293" /></p>
<p>Though there was this error which TechieDan experienced</p>
<blockquote><p><span style="color: #ff0000;"><em>org.springframework.orm.hibernate3.HibernateSystemException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.tm.ccpm.biz.domain.product.ProductSubCategory.setIdelivery;</em></span></p></blockquote>
<p>Surprisingly the mistake wasn&#8217;t software based. After looking through Hibernate.org websites and other sites for help, it was because of a simple mistake. While <strong>creating the field of IDELIVERY</strong> into the table, the default value was <span style="color: #0000ff;"><strong>null</strong></span>, and considering that the <strong>IDELIVERY column is integer</strong>, it should be defaulted to a default value. So since the column was created earlier with a <strong>null value</strong>, all that was needed to be done is to update the data in the table to repair this error.</p>
<p>Here&#8217;s what I did and it finally is running once again.</p>
<blockquote><p>update TABLENAME set IDELIVERY = 0;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://techiedan.com/2009/12/17/hibernate-error-exception-setting-property-value/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Sample HQL Query</title>
		<link>http://techiedan.com/2009/01/21/sample-hql-query/</link>
		<comments>http://techiedan.com/2009/01/21/sample-hql-query/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 07:23:40 +0000</pubDate>
		<dc:creator>techieDan</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[hql]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://techiedan.com/?p=275</guid>
		<description><![CDATA[<p>For those Java like programmers, they will be using pure SQL statements to get the whole of a table by typing the typical SQL query statement.</p>
String SQL = "select * from tablename where condition = ?";
<p>From then onwards it can be passed to a POJO to be declared but everything has to be done one [...]]]></description>
			<content:encoded><![CDATA[<p>For those Java like programmers, they will be using pure SQL statements to get the whole of a table by typing the typical SQL query statement.</p>
<pre style="background-color:#aaaacc">String SQL = "select * from tablename where condition = ?";</pre>
<p>From then onwards it can be passed to a POJO to be declared but everything has to be done one by one where each POJO object is set one by one. I have also written a <a title="SQL Statement with Loop" href="http://techiedan.com/2008/03/15/writing-sql-statement-with-loop-objects/" target="_blank">simple complex SQL call in Java previously</a> here. Now what if you had a hibernate mode setup, it&#8217;ll be just one time setup and you&#8217;ll get it redirect to the POJO it was meant to be.</p>
<p>Though this time, I&#8217;ll be talking about how HQL Query is somewhat similar to the above SQL query.</p>
<pre style="background-color:#aaaacc">String SQL = " from tableName where condition = ?";
<span class="postbody">HibernateTemplate hibernate =
new HibernateTemplate(this.getSessionFactory());
List list = hibernate.find(SQL,"condition");</span></pre>
<p>Now in just 2 lines I can call a SQL query in a simple HQL Query. Now how simple is Hibernate, if you would like to know more about hibernate, visit hibernate.org to learn about it&#8217;s framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://techiedan.com/2009/01/21/sample-hql-query/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

