<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4960343692498553851</id><updated>2012-01-18T03:09:56.615-08:00</updated><category term='NHibernate'/><category term='NHibernate in Action'/><title type='text'>NHibernation</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://nhibernation.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4960343692498553851/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://nhibernation.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Muhammad Shehabeddeen</name><uri>http://www.blogger.com/profile/11226376179446621471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_kBKjDJv0wo8/SOPy_YUE2DI/AAAAAAAAAE8/YamYGMbUgNg/S220/betterMoi2.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4960343692498553851.post-4763398554212431364</id><published>2009-07-09T01:00:00.000-07:00</published><updated>2009-07-09T01:03:03.102-07:00</updated><title type='text'>Conditional Order By Clause in HQL</title><content type='html'>For reasons I have not yet found, a query including an order by statement like below does not seem to work:&lt;br /&gt;&lt;div style='background-color: lemonchiffon; border: 1px solid black; padding: 5px; font-family: courier new; font-weight: bold'&gt;"From Rate R &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Where (R.EndEffectiveDate Is Null And R.BeginEffectiveDate &amp;lt; :oldDate) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Or &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R.EndEffectiveDate &amp;lt; :oldDate&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; And&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R.Zone = :zone And R.PriceList.Supplier = :supplier And R.PriceList.Customer = :customer&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ORDER BY &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Case When R.EndEffectiveDate Is Null then R.BeginEffectiveDate else R.EndEffectiveDate end) desc"&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4960343692498553851-4763398554212431364?l=nhibernation.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nhibernation.blogspot.com/feeds/4763398554212431364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4960343692498553851&amp;postID=4763398554212431364' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4960343692498553851/posts/default/4763398554212431364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4960343692498553851/posts/default/4763398554212431364'/><link rel='alternate' type='text/html' href='http://nhibernation.blogspot.com/2009/07/conditional-order-by-clause-in-hql.html' title='Conditional Order By Clause in HQL'/><author><name>Muhammad Shehabeddeen</name><uri>http://www.blogger.com/profile/11226376179446621471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_kBKjDJv0wo8/SOPy_YUE2DI/AAAAAAAAAE8/YamYGMbUgNg/S220/betterMoi2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4960343692498553851.post-1294559762133035572</id><published>2008-10-23T20:27:00.000-07:00</published><updated>2008-10-23T21:23:41.049-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NHibernate in Action'/><category scheme='http://www.blogger.com/atom/ns#' term='NHibernate'/><title type='text'>NHibernate in Action, Working with persistent objects, Using business key equality</title><content type='html'>This is one of a series of posts I will be doing as notes, ideas, questions and comments on content from the book NHibernate in Action.&lt;br /&gt;While explaining the importance of a Business Key and how &lt;span style="font-style: italic;"&gt;business key equality&lt;span style="font-style: italic;"&gt; &lt;/span&gt;&lt;/span&gt;should be implemented in a class by overriding the Equals method of the Object class, the author mentions the following.&lt;br /&gt;&lt;br /&gt;&lt;span style="text-decoration: underline; font-weight: bold;"&gt;Quote from book:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;"&lt;i&gt;Notice that it’s almost never correct to&lt;br /&gt;override Equals() on a subclass and include another property in the comparison. It’s tricky to satisfy the&lt;br /&gt;requirements that equality be both symmetric and transitive in this case; and, more important, the business key&lt;br /&gt;wouldn’t correspond to any well-defined candidate natural key in the database (subclass properties may be&lt;br /&gt;mapped to a different table).&lt;/i&gt;"&lt;br /&gt;&lt;br /&gt;This is not clear especially if we consider the following:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;it would be tricky for equality to be both symmetric and transitive only if we are comparing (using Equals) an object of the base class with an object from the subclass. That does not seem like a thing that would usually be done since the base class is usually abstract. Take for example the example mentioned in the book: Base Class is "BillingDetails", subclasses are "CreditCard" and "BankAccount".&lt;/li&gt;&lt;li&gt;If the Base Type defines an implementation for Equals (by overriding Object.Equals), and the Subtype also defines its implementation of Equals (by overriding the implementation of BaseType), and we are referencing an object of the Subtype using a reference of the Base Type, then the Base Type Equals method will NOT be called. So the above argument does not hold if we are considering something like:&lt;br /&gt;&lt;br /&gt;&lt;div style="border: 1px solid black; padding: 5px; background-color: lemonchiffon; font-family: courier new; font-weight: bold;"&gt;SubType obj1 = new SubType();&lt;br /&gt;&lt;br /&gt;//some code to set the obj1 to a certain state&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;SubType obj2 = new SubType();&lt;br /&gt;&lt;br /&gt;//some code to set the obj2 to same state as obj1&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;BaseType ref1 = obj1;&lt;br /&gt;&lt;br /&gt;//the following statements are equivalent&lt;br /&gt;ref1.Equals(obj2);&lt;br /&gt;obj2.Equals(ref1);&lt;/div&gt;&lt;br /&gt;So the above statements where Equals is called are equivalent.  &lt;/li&gt;&lt;/ol&gt;I can understand how &lt;i&gt;"the business key wouldn’t correspond to any well-defined candidate natural key in the database&lt;/i&gt;", it is just there for completeness.&lt;br /&gt;&lt;br /&gt;So  I am not sure what exactly the author meant, does he mean the specific case when we are comparing objects of different classes (one of the base type and another of a sub-type)? If so then maybe he should have provided such a constraint in his text.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4960343692498553851-1294559762133035572?l=nhibernation.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nhibernation.blogspot.com/feeds/1294559762133035572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4960343692498553851&amp;postID=1294559762133035572' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4960343692498553851/posts/default/1294559762133035572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4960343692498553851/posts/default/1294559762133035572'/><link rel='alternate' type='text/html' href='http://nhibernation.blogspot.com/2008/10/nhibernate-in-action-working-with.html' title='NHibernate in Action, Working with persistent objects, Using business key equality'/><author><name>Muhammad Shehabeddeen</name><uri>http://www.blogger.com/profile/11226376179446621471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_kBKjDJv0wo8/SOPy_YUE2DI/AAAAAAAAAE8/YamYGMbUgNg/S220/betterMoi2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4960343692498553851.post-8682442752246015563</id><published>2008-10-10T17:03:00.000-07:00</published><updated>2008-10-10T17:07:45.932-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NHibernate'/><title type='text'>Hello World!</title><content type='html'>Welcome. This blog is intended as a repository of information related to NHibernate. Anyone interested in contributing, please contact me either by email (muhammadshehabeddeen@gmail.com) or here by commenting.&lt;br /&gt;To kick it off, I will be posting my notes on the book "NHibernate in Action" (draft) as I read through it. I have a few notes ready, so expect another post soon.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4960343692498553851-8682442752246015563?l=nhibernation.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nhibernation.blogspot.com/feeds/8682442752246015563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4960343692498553851&amp;postID=8682442752246015563' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4960343692498553851/posts/default/8682442752246015563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4960343692498553851/posts/default/8682442752246015563'/><link rel='alternate' type='text/html' href='http://nhibernation.blogspot.com/2008/10/hello-world.html' title='Hello World!'/><author><name>Muhammad Shehabeddeen</name><uri>http://www.blogger.com/profile/11226376179446621471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_kBKjDJv0wo8/SOPy_YUE2DI/AAAAAAAAAE8/YamYGMbUgNg/S220/betterMoi2.jpg'/></author><thr:total>0</thr:total></entry></feed>
