Main Operations Examples
Equal Long Value
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("id", Operation.EQUAL, 1L));
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
where
s1_0.id=?
Equal Double Number
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("gpa", Operation.EQUAL, 3.2));
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
where
s1_0.gpa=?
Equal Long Value Inside a Related Object
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("community.id", Operation.EQUAL, 5L));
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
where
s1_0.community_id=?
Equal LocalDate
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("dateOfBirth", Operation.EQUAL, LocalDate.of(1997, 5, 7)));
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
where
s1_0.date_of_birth=?
In Long Values
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("students.id", Operation.IN, 1, 2));
GeneralSpecification<Community> communityGeneralSpecification = new GeneralSpecification<>(dataManipulationModel);
communityRepository.findAll(communityGeneralSpecification);
select
c1_0.id,
c1_0.class_name,
c1_0.teacher
from
community c1_0
join
student s1_0
on c1_0.id=s1_0.community_id
where
// highlight-next-line
s1_0.id in (?, ?)
In String Value
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("gpaLetter", Operation.IN, "A", "A-", "A+"));
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
where
s1_0.gpa_letter in (?, ?, ?)
Not In String Value
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("gpaLetter", Operation.NOT_IN, "A", "A-", "A+"));
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
where
s1_0.gpa_letter not in (?, ?, ?)
In Without Values
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("id", Operation.IN));
GeneralSpecification<Community> communityGeneralSpecification = new GeneralSpecification<>(dataManipulationModel);
communityRepository.findAll(communityGeneralSpecification);
select
c1_0.id,
c1_0.class_name,
c1_0.teacher
from
community c1_0
where
// highlight-next-line
1=0
Like
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("firstName", Operation.LIKE, "%Aya%"));
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
where
s1_0.first_name like ? escape ''
Not Like
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("firstName", Operation.NOT_LIKE, "%Aya%"));
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
where
s1_0.first_name not like ? escape ''
Like String Value Inside a Related Object
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("students.lastName", Operation.LIKE, "Ri%"));
GeneralSpecification<Community> communityGeneralSpecification = new GeneralSpecification<>(dataManipulationModel);
communityRepository.findAll(communityGeneralSpecification);
select
c1_0.id,
c1_0.class_name,
c1_0.teacher
from
community c1_0
join
student s1_0
on c1_0.id=s1_0.community_id
where
s1_0.last_name like ? escape ''
Greater Than
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("gpa", Operation.GREATER_THAN, 3.2));
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
where
s1_0.gpa>?
Greater Than Or Equal
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("gpa", Operation.GREATER_THAN_EQUAL, 3.2));
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
where
s1_0.gpa>=?
Less Than
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("gpa", Operation.LESS_THAN, 3.2));
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
where
s1_0.gpa<?
Less Than Or Equal
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("gpa", Operation.LESS_THAN_EQUAL, 3.2));
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
where
s1_0.gpa<=?
Greater Than LocalDate
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("dateOfBirth", Operation.GREATER_THAN, LocalDate.of(1997, 5, 7)));
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
where
s1_0.date_of_birth>?
Is Empty String
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("address", Operation.IS_EMPTY_STRING));
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
where
s1_0.address=?
Is Not Empty String
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("address", Operation.IS_NOT_EMPTY_STRING));
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
where
s1_0.address<>?
Is Null
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("community", Operation.IS_NULL));
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
where
// highlight-next-line
s1_0.community_id is null
Is True
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("isFullTime", Operation.IS_TRUE));
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
where
s1_0.is_full_time=?
Is False
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("isFullTime", Operation.IS_FALSE));
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
where
s1_0.is_full_time=?
Between Double
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("gpa", Operation.BETWEEN, 3.2, 3.9));
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
where
s1_0.gpa between ? and ?
Between Date
- Java
- SQL
DataManipulationModel dataManipulationModel = new DataManipulationModel();
dataManipulationModel.setCriteria(condition("enrollmentDate", Operation.BETWEEN, LocalDate.of(2022, 2, 15),
LocalDate.of(2022, 7, 1)));
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
where
s1_0.enrollment_date between ? and ?