Monday 15 June 2015

java - What does the 'sort' attribute do? -


The following is a snippet from the hibernate mapping file, which is m1 of the named class.

  & lt; Class name = "pojo.m1" table = "m1" & gt; & Lt; Id name = "r_no" & gt; & Lt; Generator class = "increment increase" /> & Lt; / Id & gt; & Lt; Property Name = "s_name" /> & Lt; Map name = "map" table = "m4" cascade = "all" type = "poz.m4" & gt; & Lt; Major column = "r_no" /> & Lt; Index-many-to-many classes = "pojo.m2" column = "T1" /> & Lt ;! - In the form of R_OO index! - & gt; & Lt; Many-to-many classes = "pojo.m3" column = "t2" /> & Lt ;! - r_no + as the total or class M3 key! - & gt; & Lt; / Map & gt; & Lt; / Square & gt; In the   

map tag, there is a feature named sort . What does it do? Here it gives the name of the class which implements the comparator class.

  Public Class M4 applies Comparator & lt; M2 & gt; {@ Override Public Int Comparison (M2O1, M2O2) {if (o1.getR_no () & gt; o 2.getR_no ()) returns 1; Other return -1; }}    

From:

  Optional): Specifies the sort sorted with natural sort order or given comparator class.   

Specifies that your map archive is sorted and in which order it has been sorted. In your case a comparator is given which defines the order of two objects and therefore iterates the order of all objects.

No comments:

Post a Comment