<?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: Sorting Hibernate Set using a comparator</title>
	<atom:link href="http://parasjain.net/2008/11/10/sorting-hibernate-set-using-a-comparator/feed/" rel="self" type="application/rss+xml" />
	<link>http://parasjain.net/2008/11/10/sorting-hibernate-set-using-a-comparator/</link>
	<description>IT happens only in IT</description>
	<lastBuildDate>Sun, 13 Nov 2011 03:16:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: 2010 in review &#171; Techspace</title>
		<link>http://parasjain.net/2008/11/10/sorting-hibernate-set-using-a-comparator/#comment-303</link>
		<dc:creator><![CDATA[2010 in review &#171; Techspace]]></dc:creator>
		<pubDate>Tue, 04 Jan 2011 16:00:16 +0000</pubDate>
		<guid isPermaLink="false">http://parasjain01.wordpress.com/?p=41#comment-303</guid>
		<description><![CDATA[[...] Sorting Hibernate Set using a comparator November 200810 comments  5 [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Sorting Hibernate Set using a comparator November 200810 comments  5 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paras</title>
		<link>http://parasjain.net/2008/11/10/sorting-hibernate-set-using-a-comparator/#comment-94</link>
		<dc:creator><![CDATA[Paras]]></dc:creator>
		<pubDate>Fri, 08 May 2009 00:50:30 +0000</pubDate>
		<guid isPermaLink="false">http://parasjain01.wordpress.com/?p=41#comment-94</guid>
		<description><![CDATA[What I understand from the scenario that you have list of to-dos and every ToDO has a priority. 

I am confused at the exact scenario. I guess the scenario could be one of the following

i) Scenario 1 - You are showing the list of ToDos on some page and by default the ToDos are coming in the order of HLM and you want in HML order. In that case you must be holding ToDos in some collection and that collection will sort in the order of natural sorting. In order to override that your ToDo class has to implement Comparable interface and you have to write compareTo method accordingly. It is a good idea to implement equals and hashcode also for ToDo class.
One more thing, the collection you must use for this should be TreeSet or any collection implementing SortedSet interface. I guess currently the results of your HQL query is being stored in Arraylist or something


ii)Scenario 2 -  Another scenario could be you are showing priorities in the dropdown or somewhere and your browser is shoing priorites in wrong order. In that case try Priority should implement comparable interface or your view layer should re-order

Please not that neither of this scenario is related to my original blog post where you have set for a class. In this case you don&#039;t have Set you have many to one relationship. One ToDo has only one priority. My blog post could be relevant had you had multiple priorities for one ToDo and you want to order them in some specific pattern. 

Hope this makes it clear. Let me know if you have any questions

]]></description>
		<content:encoded><![CDATA[<p>What I understand from the scenario that you have list of to-dos and every ToDO has a priority. </p>
<p>I am confused at the exact scenario. I guess the scenario could be one of the following</p>
<p>i) Scenario 1 &#8211; You are showing the list of ToDos on some page and by default the ToDos are coming in the order of HLM and you want in HML order. In that case you must be holding ToDos in some collection and that collection will sort in the order of natural sorting. In order to override that your ToDo class has to implement Comparable interface and you have to write compareTo method accordingly. It is a good idea to implement equals and hashcode also for ToDo class.<br />
One more thing, the collection you must use for this should be TreeSet or any collection implementing SortedSet interface. I guess currently the results of your HQL query is being stored in Arraylist or something</p>
<p>ii)Scenario 2 &#8211;  Another scenario could be you are showing priorities in the dropdown or somewhere and your browser is shoing priorites in wrong order. In that case try Priority should implement comparable interface or your view layer should re-order</p>
<p>Please not that neither of this scenario is related to my original blog post where you have set for a class. In this case you don&#8217;t have Set you have many to one relationship. One ToDo has only one priority. My blog post could be relevant had you had multiple priorities for one ToDo and you want to order them in some specific pattern. </p>
<p>Hope this makes it clear. Let me know if you have any questions</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: salvin francis</title>
		<link>http://parasjain.net/2008/11/10/sorting-hibernate-set-using-a-comparator/#comment-93</link>
		<dc:creator><![CDATA[salvin francis]]></dc:creator>
		<pubDate>Thu, 07 May 2009 05:34:42 +0000</pubDate>
		<guid isPermaLink="false">http://parasjain01.wordpress.com/?p=41#comment-93</guid>
		<description><![CDATA[Todo contains Priority:
todo relationship
&lt;code&gt;
&lt;many-to-one
  name=&quot;prtyHdr&quot;
  class=[priority class name]
  not-null=&quot;true&quot;
&gt;
&lt;column name=&quot;PR_ID&quot;/&gt;
&lt;/many-to-one&gt;
&lt;/code&gt;

priority relationship
&lt;code&gt;
&lt;set
  name=&quot;todoLogs&quot;
  lazy=&quot;true&quot;
  inverse=&quot;true&quot;
  cascade=&quot;all&quot;
&gt;
&lt;key&gt;
&lt;column name=&quot;PR_ID&quot;/&gt;
&lt;/key&gt;
 &lt;one-to-many
  class=[todo class name]
  /&gt;
&lt;/set&gt;
&lt;/code&gt;
actual ordering in priority (alphabetically):
&quot;High&quot;,&quot;Low&quot;,&quot;Medium&quot;
required order:
&quot;High&quot;,&quot;Medium&quot;,&quot;Low&quot;
]]></description>
		<content:encoded><![CDATA[<p>Todo contains Priority:<br />
todo relationship<br />
&lt;code&gt;<br />
&lt;many-to-one<br />
  name=&quot;prtyHdr&quot;<br />
  class=[priority class name]<br />
  not-null=&quot;true&quot;<br />
&gt;<br />
&lt;column name=&quot;PR_ID&quot;/&gt;<br />
&lt;/many-to-one&gt;<br />
&lt;/code&gt;</p>
<p>priority relationship<br />
&lt;code&gt;<br />
&lt;set<br />
  name=&quot;todoLogs&quot;<br />
  lazy=&quot;true&quot;<br />
  inverse=&quot;true&quot;<br />
  cascade=&quot;all&quot;<br />
&gt;<br />
&lt;key&gt;<br />
&lt;column name=&quot;PR_ID&quot;/&gt;<br />
&lt;/key&gt;<br />
 &lt;one-to-many<br />
  class=[todo class name]<br />
  /&gt;<br />
&lt;/set&gt;<br />
&lt;/code&gt;<br />
actual ordering in priority (alphabetically):<br />
&quot;High&quot;,&quot;Low&quot;,&quot;Medium&quot;<br />
required order:<br />
&quot;High&quot;,&quot;Medium&quot;,&quot;Low&quot;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: salvin francis</title>
		<link>http://parasjain.net/2008/11/10/sorting-hibernate-set-using-a-comparator/#comment-92</link>
		<dc:creator><![CDATA[salvin francis]]></dc:creator>
		<pubDate>Thu, 07 May 2009 05:33:59 +0000</pubDate>
		<guid isPermaLink="false">http://parasjain01.wordpress.com/?p=41#comment-92</guid>
		<description><![CDATA[Todo contains Priority:

todo relationship

&lt;code&gt;

  
 
&lt;/code&gt;


priority relationship

&lt;code&gt;

  
	 
  

 
 
&lt;/code&gt;

actual ordering in priority (alphabetically):
&quot;High&quot;,&quot;Low&quot;,&quot;Medium&quot;

required order:
&quot;High&quot;,&quot;Medium&quot;,&quot;Low&quot;]]></description>
		<content:encoded><![CDATA[<p>Todo contains Priority:</p>
<p>todo relationship</p>
<p><code></p>
<p></code></p>
<p>priority relationship</p>
<p><code></p>
<p></code></p>
<p>actual ordering in priority (alphabetically):<br />
&#8220;High&#8221;,&#8221;Low&#8221;,&#8221;Medium&#8221;</p>
<p>required order:<br />
&#8220;High&#8221;,&#8221;Medium&#8221;,&#8221;Low&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: salvin francis</title>
		<link>http://parasjain.net/2008/11/10/sorting-hibernate-set-using-a-comparator/#comment-91</link>
		<dc:creator><![CDATA[salvin francis]]></dc:creator>
		<pubDate>Thu, 07 May 2009 05:21:21 +0000</pubDate>
		<guid isPermaLink="false">http://parasjain01.wordpress.com/?p=41#comment-91</guid>
		<description><![CDATA[how do i submit xml code in post? the site uses some special tags i guess...]]></description>
		<content:encoded><![CDATA[<p>how do i submit xml code in post? the site uses some special tags i guess&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: salvin francis</title>
		<link>http://parasjain.net/2008/11/10/sorting-hibernate-set-using-a-comparator/#comment-90</link>
		<dc:creator><![CDATA[salvin francis]]></dc:creator>
		<pubDate>Thu, 07 May 2009 04:57:18 +0000</pubDate>
		<guid isPermaLink="false">http://parasjain01.wordpress.com/?p=41#comment-90</guid>
		<description><![CDATA[[code]
todo relationship


  
 



priority relationship


  
	 
  

 
 
[/code]]]></description>
		<content:encoded><![CDATA[<pre class="brush: plain;">
todo relationship

priority relationship
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: salvin francis</title>
		<link>http://parasjain.net/2008/11/10/sorting-hibernate-set-using-a-comparator/#comment-89</link>
		<dc:creator><![CDATA[salvin francis]]></dc:creator>
		<pubDate>Thu, 07 May 2009 04:53:07 +0000</pubDate>
		<guid isPermaLink="false">http://parasjain01.wordpress.com/?p=41#comment-89</guid>
		<description><![CDATA[well i m sorry i cant share tht wid you (company code)

but here is the thing i can say:

something called &quot;todo&quot; in my application has a many-to-one relation with &quot;priority&quot;

so todo relation is:

  


and the priority hbm file contains:

 
 
 
 



the HQL query (i am not allowed to use SQL) uses orderby

The issue is priority is sorted Alphabetically, however
this is not correct for &quot;High&quot;,&quot;Medium&quot;,&quot;Low&quot; (since &quot;L&quot; comes before &quot;M&quot;)
someone suggested me to use lowercase for &quot;l&quot; but i consider that a Hack.]]></description>
		<content:encoded><![CDATA[<p>well i m sorry i cant share tht wid you (company code)</p>
<p>but here is the thing i can say:</p>
<p>something called &#8220;todo&#8221; in my application has a many-to-one relation with &#8220;priority&#8221;</p>
<p>so todo relation is:</p>
<p>and the priority hbm file contains:</p>
<p>the HQL query (i am not allowed to use SQL) uses orderby</p>
<p>The issue is priority is sorted Alphabetically, however<br />
this is not correct for &#8220;High&#8221;,&#8221;Medium&#8221;,&#8221;Low&#8221; (since &#8220;L&#8221; comes before &#8220;M&#8221;)<br />
someone suggested me to use lowercase for &#8220;l&#8221; but i consider that a Hack.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paras</title>
		<link>http://parasjain.net/2008/11/10/sorting-hibernate-set-using-a-comparator/#comment-88</link>
		<dc:creator><![CDATA[Paras]]></dc:creator>
		<pubDate>Wed, 06 May 2009 18:31:48 +0000</pubDate>
		<guid isPermaLink="false">http://parasjain01.wordpress.com/?p=41#comment-88</guid>
		<description><![CDATA[Hi Salvin,
Please share your mapping file.]]></description>
		<content:encoded><![CDATA[<p>Hi Salvin,<br />
Please share your mapping file.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: salvin francis</title>
		<link>http://parasjain.net/2008/11/10/sorting-hibernate-set-using-a-comparator/#comment-87</link>
		<dc:creator><![CDATA[salvin francis]]></dc:creator>
		<pubDate>Wed, 06 May 2009 08:34:13 +0000</pubDate>
		<guid isPermaLink="false">http://parasjain01.wordpress.com/?p=41#comment-87</guid>
		<description><![CDATA[What if there is no set ?

I am using a Many-to-one relationship where
i want to custom sort the child, wht do i do ?]]></description>
		<content:encoded><![CDATA[<p>What if there is no set ?</p>
<p>I am using a Many-to-one relationship where<br />
i want to custom sort the child, wht do i do ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paras</title>
		<link>http://parasjain.net/2008/11/10/sorting-hibernate-set-using-a-comparator/#comment-60</link>
		<dc:creator><![CDATA[Paras]]></dc:creator>
		<pubDate>Tue, 06 Jan 2009 14:47:29 +0000</pubDate>
		<guid isPermaLink="false">http://parasjain01.wordpress.com/?p=41#comment-60</guid>
		<description><![CDATA[Hello, 
I could not get your question fully. What number sorter you want to use? Is your primary key a Class? What is the relation between the number and the primary key? Please explain the scenario]]></description>
		<content:encoded><![CDATA[<p>Hello,<br />
I could not get your question fully. What number sorter you want to use? Is your primary key a Class? What is the relation between the number and the primary key? Please explain the scenario</p>
]]></content:encoded>
	</item>
</channel>
</rss>

