Sorting
If u want to sort ur models, Firstly u have to implement "Comaprable" Interface,which is the part of "java.lang" package.And then IF u getting collection from the DAO.then write the one line:
if u r using JDK 1.5
Collections.sort(urDAORetaunredList);
This will sort the "urDAORetaunredList" alphabeticaly in case of String.
Model code
Code:
import java.util.Date;
import javax.persistence.*;
@Entity
@Table(name = "routes")
public class RoutesModel extends AbstractBaseModel implements Comparable<RoutesModel> {
private String pattern;
private String comment;
public RoutesModel(){
}
public void setPattern(String pattern){
this.pattern = pattern;
}
@Column(name = "pattern" )
public String getPattern(){
return this.pattern;
}
public void setComment(String comment){
this.comment = comment;
}
@Column(name = "comment" )
public String getComment(){
return this.comment;
}
public int compareTo(RoutesModel comparedObject) {
// TODO Auto-generated method stub
return this.getComment().compareToIgnoreCase(comparedObject.getComment());
}
}
Regards,
Shahzad Ahsan
Ooober Brain
ooober.com