Sort Examples
Sort ASC
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setSortModel(asc("gpa"));
GeneralSpecification<Student> studentGeneralSpecification = new GeneralSpecification<>(dataManipulationModel);
studentRepository.findAll(studentGeneralSpecification);
select
s1_0.id,
s1_0.additional_info,
s1_0.address,
s1_0.community_id,
s1_0.date_of_birth,
s1_0.email,
s1_0.enrollment_date,
s1_0.first_name,
s1_0.gpa,
s1_0.gpa_letter,
s1_0.is_full_time,
s1_0.last_name,
s1_0.phone_number
from
student s1_0
order by
s1_0.gpa
Sort DESC
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setSortModel(desc("gpa"));
GeneralSpecification<Student> studentGeneralSpecification = new GeneralSpecification<>(dataManipulationModel);
studentRepository.findAll(studentGeneralSpecification);
select
s1_0.id,
s1_0.additional_info,
s1_0.address,
s1_0.community_id,
s1_0.date_of_birth,
s1_0.email,
s1_0.enrollment_date,
s1_0.first_name,
s1_0.gpa,
s1_0.gpa_letter,
s1_0.is_full_time,
s1_0.last_name,
s1_0.phone_number
from
student s1_0
order by
s1_0.gpa desc
Multi Sort DESC and ASC (1)
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setSortModel(desc("gpa"), asc("firstName"));
GeneralSpecification<Student> studentGeneralSpecification = new GeneralSpecification<>(dataManipulationModel);
studentRepository.findAll(studentGeneralSpecification);
select
s1_0.id,
s1_0.additional_info,
s1_0.address,
s1_0.community_id,
s1_0.date_of_birth,
s1_0.email,
s1_0.enrollment_date,
s1_0.first_name,
s1_0.gpa,
s1_0.gpa_letter,
s1_0.is_full_time,
s1_0.last_name,
s1_0.phone_number
from
student s1_0
order by
s1_0.gpa desc,
s1_0.first_name
Multi Sort DESC and ASC (2)
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setSortModel(asc("gpa"), desc("firstName"));
GeneralSpecification<Student> studentGeneralSpecification = new GeneralSpecification<>(dataManipulationModel);
studentRepository.findAll(studentGeneralSpecification);
select
s1_0.id,
s1_0.additional_info,
s1_0.address,
s1_0.community_id,
s1_0.date_of_birth,
s1_0.email,
s1_0.enrollment_date,
s1_0.first_name,
s1_0.gpa,
s1_0.gpa_letter,
s1_0.is_full_time,
s1_0.last_name,
s1_0.phone_number
from
student s1_0
order by
s1_0.gpa,
s1_0.first_name desc