Java Code Examples for org.springframework.data.jpa.domain.Specification#and()
The following examples show how to use
org.springframework.data.jpa.domain.Specification#and() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobSqlQueryService.java From alchemy with Apache License 2.0 | 6 votes |
/** * Function to convert JobSqlCriteria to a {@link Specification}. */ private Specification<JobSql> createSpecification(JobSqlCriteria criteria) { Specification<JobSql> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), JobSql_.id)); } if (criteria.getCreatedBy() != null) { specification = specification.and(buildStringSpecification(criteria.getCreatedBy(), JobSql_.createdBy)); } if (criteria.getCreatedDate() != null) { specification = specification.and(buildRangeSpecification(criteria.getCreatedDate(), JobSql_.createdDate)); } if (criteria.getLastModifiedBy() != null) { specification = specification.and(buildStringSpecification(criteria.getLastModifiedBy(), JobSql_.lastModifiedBy)); } if (criteria.getLastModifiedDate() != null) { specification = specification.and(buildRangeSpecification(criteria.getLastModifiedDate(), JobSql_.lastModifiedDate)); } if (criteria.getJobId() != null) { specification = specification.and(buildSpecification(criteria.getJobId(), root -> root.join(JobSql_.job, JoinType.LEFT).get(Job_.id))); } } return specification; }
Example 2
Source File: AuditDao.java From JuniperBot with GNU General Public License v3.0 | 6 votes |
@Transactional public List<AuditActionDto> getActions(long guildId, AuditActionRequest request) { Specification<AuditAction> spec = rootAuditSpec(guildId); if (request != null) { if (request.getActionType() != null) { spec = spec.and(withActionType(request.getActionType())); } if (request.getUserId() != null) { spec = spec.and(withUserId(request.getUserId())); } if (request.getChannelId() != null) { spec = spec.and(withChannelId(request.getChannelId())); } if (request.getOlderThan() != null) { spec = spec.and(withOlderThan(request.getOlderThan())); } if (request.getStartDate() != null) { spec = spec.and(withStartDate(request.getStartDate())); } if (request.getEndDate() != null) { spec = spec.and(withEndDate(request.getEndDate())); } } List<AuditAction> actions = actionRepository.findAll(spec, PageRequest.of(0, 50)).getContent(); return apiMapper.getAuditActionDtos(actions); }
Example 3
Source File: ActivityQueryService.java From TeamDojo with Apache License 2.0 | 6 votes |
/** * Function to convert ActivityCriteria to a {@link Specification} */ private Specification<Activity> createSpecification(ActivityCriteria criteria) { Specification<Activity> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Activity_.id)); } if (criteria.getType() != null) { specification = specification.and(buildSpecification(criteria.getType(), Activity_.type)); } if (criteria.getData() != null) { specification = specification.and(buildStringSpecification(criteria.getData(), Activity_.data)); } if (criteria.getCreatedAt() != null) { specification = specification.and(buildRangeSpecification(criteria.getCreatedAt(), Activity_.createdAt)); } } return specification; }
Example 4
Source File: QuoteQueryService.java From tutorials with MIT License | 6 votes |
/** * Function to convert QuoteCriteria to a {@link Specification} */ private Specification<Quote> createSpecification(QuoteCriteria criteria) { Specification<Quote> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Quote_.id)); } if (criteria.getSymbol() != null) { specification = specification.and(buildStringSpecification(criteria.getSymbol(), Quote_.symbol)); } if (criteria.getPrice() != null) { specification = specification.and(buildRangeSpecification(criteria.getPrice(), Quote_.price)); } if (criteria.getLastTrade() != null) { specification = specification.and(buildRangeSpecification(criteria.getLastTrade(), Quote_.lastTrade)); } } return specification; }
Example 5
Source File: LevelSkillQueryService.java From TeamDojo with Apache License 2.0 | 6 votes |
/** * Function to convert LevelSkillCriteria to a {@link Specification} */ private Specification<LevelSkill> createSpecification(LevelSkillCriteria criteria) { Specification<LevelSkill> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), LevelSkill_.id)); } if (criteria.getSkillId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getSkillId(), LevelSkill_.skill, Skill_.id)); } if (criteria.getLevelId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getLevelId(), LevelSkill_.level, Level_.id)); } } return specification; }
Example 6
Source File: CommentQueryService.java From TeamDojo with Apache License 2.0 | 6 votes |
/** * Function to convert CommentCriteria to a {@link Specification} */ private Specification<Comment> createSpecification(CommentCriteria criteria) { Specification<Comment> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Comment_.id)); } if (criteria.getText() != null) { specification = specification.and(buildStringSpecification(criteria.getText(), Comment_.text)); } if (criteria.getCreationDate() != null) { specification = specification.and(buildRangeSpecification(criteria.getCreationDate(), Comment_.creationDate)); } if (criteria.getTeamId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getTeamId(), Comment_.team, Team_.id)); } if (criteria.getSkillId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getSkillId(), Comment_.skill, Skill_.id)); } } return specification; }
Example 7
Source File: ReportQueryService.java From TeamDojo with Apache License 2.0 | 6 votes |
/** * Function to convert ReportCriteria to a {@link Specification} */ private Specification<Report> createSpecification(ReportCriteria criteria) { Specification<Report> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Report_.id)); } if (criteria.getTitle() != null) { specification = specification.and(buildStringSpecification(criteria.getTitle(), Report_.title)); } if (criteria.getDescription() != null) { specification = specification.and(buildStringSpecification(criteria.getDescription(), Report_.description)); } if (criteria.getType() != null) { specification = specification.and(buildSpecification(criteria.getType(), Report_.type)); } if (criteria.getCreationDate() != null) { specification = specification.and(buildRangeSpecification(criteria.getCreationDate(), Report_.creationDate)); } } return specification; }
Example 8
Source File: SinkQueryService.java From alchemy with Apache License 2.0 | 5 votes |
/** * Function to convert SinkCriteria to a {@link Specification}. */ private Specification<Sink> createSpecification(SinkCriteria criteria) { Specification<Sink> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Sink_.id)); } if (criteria.getName() != null) { specification = specification.and(buildStringSpecification(criteria.getName(), Sink_.name)); } if (criteria.getType() != null) { specification = specification.and(buildSpecification(criteria.getType(), Sink_.type)); } if (criteria.getRemark() != null) { specification = specification.and(buildStringSpecification(criteria.getRemark(), Sink_.remark)); } if (criteria.getCreatedBy() != null) { specification = specification.and(buildStringSpecification(criteria.getCreatedBy(), Sink_.createdBy)); } if (criteria.getCreatedDate() != null) { specification = specification.and(buildRangeSpecification(criteria.getCreatedDate(), Sink_.createdDate)); } if (criteria.getLastModifiedBy() != null) { specification = specification.and(buildStringSpecification(criteria.getLastModifiedBy(), Sink_.lastModifiedBy)); } if (criteria.getLastModifiedDate() != null) { specification = specification.and(buildRangeSpecification(criteria.getLastModifiedDate(), Sink_.lastModifiedDate)); } if (criteria.getBusinessId() != null) { specification = specification.and(buildSpecification(criteria.getBusinessId(), root -> root.join(Sink_.business, JoinType.LEFT).get(Business_.id))); } } return specification; }
Example 9
Source File: ChildEntityQueryService.java From jhipster with Apache License 2.0 | 5 votes |
public Specification<ChildEntity> createSpecification(ChildEntityCriteria criteria) { Specification<ChildEntity> specification = Specification.where(null); if (criteria.getParentId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getParentId(), ChildEntity_.parent, ParentEntity_.id)); } return specification; }
Example 10
Source File: TeamSkillQueryService.java From TeamDojo with Apache License 2.0 | 5 votes |
/** * Function to convert TeamSkillCriteria to a {@link Specification} */ private Specification<TeamSkill> createSpecification(TeamSkillCriteria criteria) { Specification<TeamSkill> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), TeamSkill_.id)); } if (criteria.getCompletedAt() != null) { specification = specification.and(buildRangeSpecification(criteria.getCompletedAt(), TeamSkill_.completedAt)); } if (criteria.getVerifiedAt() != null) { specification = specification.and(buildRangeSpecification(criteria.getVerifiedAt(), TeamSkill_.verifiedAt)); } if (criteria.getIrrelevant() != null) { specification = specification.and(buildSpecification(criteria.getIrrelevant(), TeamSkill_.irrelevant)); } if (criteria.getNote() != null) { specification = specification.and(buildStringSpecification(criteria.getNote(), TeamSkill_.note)); } if (criteria.getSkillId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getSkillId(), TeamSkill_.skill, Skill_.id)); } if (criteria.getTeamId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getTeamId(), TeamSkill_.team, Team_.id)); } } return specification; }
Example 11
Source File: BadgeQueryService.java From TeamDojo with Apache License 2.0 | 5 votes |
/** * Function to convert BadgeCriteria to a {@link Specification} */ private Specification<Badge> createSpecification(BadgeCriteria criteria) { Specification<Badge> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Badge_.id)); } if (criteria.getName() != null) { specification = specification.and(buildStringSpecification(criteria.getName(), Badge_.name)); } if (criteria.getDescription() != null) { specification = specification.and(buildStringSpecification(criteria.getDescription(), Badge_.description)); } if (criteria.getAvailableUntil() != null) { specification = specification.and(buildRangeSpecification(criteria.getAvailableUntil(), Badge_.availableUntil)); } if (criteria.getAvailableAmount() != null) { specification = specification.and(buildRangeSpecification(criteria.getAvailableAmount(), Badge_.availableAmount)); } if (criteria.getRequiredScore() != null) { specification = specification.and(buildRangeSpecification(criteria.getRequiredScore(), Badge_.requiredScore)); } if (criteria.getInstantMultiplier() != null) { specification = specification.and(buildRangeSpecification(criteria.getInstantMultiplier(), Badge_.instantMultiplier)); } if (criteria.getCompletionBonus() != null) { specification = specification.and(buildRangeSpecification(criteria.getCompletionBonus(), Badge_.completionBonus)); } if (criteria.getSkillsId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getSkillsId(), Badge_.skills, BadgeSkill_.id)); } if (criteria.getDimensionsId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getDimensionsId(), Badge_.dimensions, Dimension_.id)); } if (criteria.getImageId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getImageId(), Badge_.image, Image_.id)); } } return specification; }
Example 12
Source File: LevelQueryService.java From TeamDojo with Apache License 2.0 | 5 votes |
/** * Function to convert LevelCriteria to a {@link Specification} */ private Specification<Level> createSpecification(LevelCriteria criteria) { Specification<Level> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Level_.id)); } if (criteria.getName() != null) { specification = specification.and(buildStringSpecification(criteria.getName(), Level_.name)); } if (criteria.getDescription() != null) { specification = specification.and(buildStringSpecification(criteria.getDescription(), Level_.description)); } if (criteria.getRequiredScore() != null) { specification = specification.and(buildRangeSpecification(criteria.getRequiredScore(), Level_.requiredScore)); } if (criteria.getInstantMultiplier() != null) { specification = specification.and(buildRangeSpecification(criteria.getInstantMultiplier(), Level_.instantMultiplier)); } if (criteria.getCompletionBonus() != null) { specification = specification.and(buildRangeSpecification(criteria.getCompletionBonus(), Level_.completionBonus)); } if (criteria.getDimensionId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getDimensionId(), Level_.dimension, Dimension_.id)); } if (criteria.getDependsOnId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getDependsOnId(), Level_.dependsOn, Level_.id)); } if (criteria.getSkillsId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getSkillsId(), Level_.skills, LevelSkill_.id)); } if (criteria.getImageId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getImageId(), Level_.image, Image_.id)); } } return specification; }
Example 13
Source File: TeamQueryService.java From TeamDojo with Apache License 2.0 | 5 votes |
/** * Function to convert TeamCriteria to a {@link Specification} */ private Specification<Team> createSpecification(TeamCriteria criteria) { Specification<Team> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Team_.id)); } if (criteria.getName() != null) { specification = specification.and(buildStringSpecification(criteria.getName(), Team_.name)); } if (criteria.getShortName() != null) { specification = specification.and(buildStringSpecification(criteria.getShortName(), Team_.shortName)); } if (criteria.getSlogan() != null) { specification = specification.and(buildStringSpecification(criteria.getSlogan(), Team_.slogan)); } if (criteria.getContactPerson() != null) { specification = specification.and(buildStringSpecification(criteria.getContactPerson(), Team_.contactPerson)); } if (criteria.getParticipationsId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getParticipationsId(), Team_.participations, Dimension_.id)); } if (criteria.getSkillsId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getSkillsId(), Team_.skills, TeamSkill_.id)); } if (criteria.getImageId() != null) { specification = specification.and(buildReferringEntitySpecification(criteria.getImageId(), Team_.image, Image_.id)); } } return specification; }
Example 14
Source File: QueryService.java From jhipster with Apache License 2.0 | 5 votes |
/** * Helper function to return a specification for filtering on one-to-many or many-to-many reference.Where equality, less than, greater than and less-than-or-equal-to and greater-than-or-equal-to and null/non-null conditions are supported. Usage: <pre><code> * Specification<Employee> specByEmployeeId = buildReferringEntitySpecification( * criteria.getEmployeId(), * root -> root.get(Project_.company).join(Company_.employees), * entity -> entity.get(Employee_.id)); * Specification<Employee> specByProjectName = buildReferringEntitySpecification( * criteria.getProjectName(), * root -> root.get(Project_.project) * entity -> entity.get(Project_.name)); * </code> * </pre> * * @param <X> The type of the attribute which is filtered. * @param filter the filter object which contains a value, which needs to match or a flag if emptiness is * checked. * @param functionToEntity the function, which joins he current entity to the entity set, on which the filtering is applied. * @param entityToColumn the function, which of the static metamodel of the referred entity, where the equality should be * checked. * @param <OTHER> The type of the referenced entity. * @param <MISC> The type of the entity which is the last before the OTHER in the chain. * @return a Specification */ protected <OTHER, MISC, X extends Comparable<? super X>> Specification<ENTITY> buildReferringEntitySpecification(final RangeFilter<X> filter, Function<Root<ENTITY>, SetJoin<MISC, OTHER>> functionToEntity, Function<SetJoin<MISC, OTHER>, Expression<X>> entityToColumn) { Function<Root<ENTITY>, Expression<X>> fused = functionToEntity.andThen(entityToColumn); if (filter.getEquals() != null) { return equalsSpecification(fused, filter.getEquals()); } else if (filter.getIn() != null) { return valueIn(fused, filter.getIn()); } Specification<ENTITY> result = Specification.where(null); if (filter.getSpecified() != null) { // Interestingly, 'functionToEntity' doesn't work, we need the longer lambda formula result = result.and(byFieldSpecified(root -> functionToEntity.apply(root), filter.getSpecified())); } if (filter.getNotEquals() != null) { result = result.and(notEqualsSpecification(fused, filter.getNotEquals())); } if (filter.getNotIn() != null) { result = result.and(valueNotIn(fused, filter.getNotIn())); } if (filter.getGreaterThan() != null) { result = result.and(greaterThan(fused, filter.getGreaterThan())); } if (filter.getGreaterThanOrEqual() != null) { result = result.and(greaterThanOrEqualTo(fused, filter.getGreaterThanOrEqual())); } if (filter.getLessThan() != null) { result = result.and(lessThan(fused, filter.getLessThan())); } if (filter.getLessThanOrEqual() != null) { result = result.and(lessThanOrEqualTo(fused, filter.getLessThanOrEqual())); } return result; }
Example 15
Source File: ImageQueryService.java From TeamDojo with Apache License 2.0 | 5 votes |
/** * Function to convert ImageCriteria to a {@link Specification} */ private Specification<Image> createSpecification(ImageCriteria criteria) { Specification<Image> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Image_.id)); } if (criteria.getName() != null) { specification = specification.and(buildStringSpecification(criteria.getName(), Image_.name)); } } return specification; }
Example 16
Source File: SourceQueryService.java From alchemy with Apache License 2.0 | 5 votes |
/** * Function to convert SourceCriteria to a {@link Specification}. */ private Specification<Source> createSpecification(SourceCriteria criteria) { Specification<Source> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Source_.id)); } if (criteria.getName() != null) { specification = specification.and(buildStringSpecification(criteria.getName(), Source_.name)); } if (criteria.getTableType() != null) { specification = specification.and(buildSpecification(criteria.getTableType(), Source_.tableType)); } if (criteria.getSourceType() != null) { specification = specification.and(buildSpecification(criteria.getSourceType(), Source_.sourceType)); } if (criteria.getRemark() != null) { specification = specification.and(buildStringSpecification(criteria.getRemark(), Source_.remark)); } if (criteria.getCreatedBy() != null) { specification = specification.and(buildStringSpecification(criteria.getCreatedBy(), Source_.createdBy)); } if (criteria.getCreatedDate() != null) { specification = specification.and(buildRangeSpecification(criteria.getCreatedDate(), Source_.createdDate)); } if (criteria.getLastModifiedBy() != null) { specification = specification.and(buildStringSpecification(criteria.getLastModifiedBy(), Source_.lastModifiedBy)); } if (criteria.getLastModifiedDate() != null) { specification = specification.and(buildRangeSpecification(criteria.getLastModifiedDate(), Source_.lastModifiedDate)); } if (criteria.getBusinessId() != null) { specification = specification.and(buildSpecification(criteria.getBusinessId(), root -> root.join(Source_.business, JoinType.LEFT).get(Business_.id))); } } return specification; }
Example 17
Source File: FieldQueryService.java From alchemy with Apache License 2.0 | 5 votes |
/** * Function to convert FieldCriteria to a {@link Specification}. */ private Specification<Field> createSpecification(FieldCriteria criteria) { Specification<Field> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Field_.id)); } if (criteria.getColumnName() != null) { specification = specification.and(buildStringSpecification(criteria.getColumnName(), Field_.columnName)); } if (criteria.getColumnType() != null) { specification = specification.and(buildStringSpecification(criteria.getColumnType(), Field_.columnType)); } if (criteria.getConfig() != null) { specification = specification.and(buildStringSpecification(criteria.getConfig(), Field_.config)); } if (criteria.getCreatedBy() != null) { specification = specification.and(buildStringSpecification(criteria.getCreatedBy(), Field_.createdBy)); } if (criteria.getCreatedDate() != null) { specification = specification.and(buildRangeSpecification(criteria.getCreatedDate(), Field_.createdDate)); } if (criteria.getLastModifiedBy() != null) { specification = specification.and(buildStringSpecification(criteria.getLastModifiedBy(), Field_.lastModifiedBy)); } if (criteria.getLastModifiedDate() != null) { specification = specification.and(buildRangeSpecification(criteria.getLastModifiedDate(), Field_.lastModifiedDate)); } if (criteria.getSourceId() != null) { specification = specification.and(buildSpecification(criteria.getSourceId(), root -> root.join(Field_.source, JoinType.LEFT).get(Source_.id))); } } return specification; }
Example 18
Source File: BaseEntityQueryService.java From jhipster with Apache License 2.0 | 5 votes |
public Specification<BaseEntity> createSpecification(BaseEntityCriteria criteria) { Specification<BaseEntity> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), BaseEntity_.id)); } if (criteria.getName() != null) { specification = specification.and(buildStringSpecification(criteria.getName(), BaseEntity_.name)); } } return specification; }
Example 19
Source File: JobQueryService.java From alchemy with Apache License 2.0 | 4 votes |
/** * Function to convert JobCriteria to a {@link Specification}. */ private Specification<Job> createSpecification(JobCriteria criteria) { Specification<Job> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Job_.id)); } if (criteria.getName() != null) { specification = specification.and(buildStringSpecification(criteria.getName(), Job_.name)); } if (criteria.getType() != null) { specification = specification.and(buildSpecification(criteria.getType(), Job_.type)); } if (criteria.getRemark() != null) { specification = specification.and(buildStringSpecification(criteria.getRemark(), Job_.remark)); } if (criteria.getClusterJobId() != null) { specification = specification.and(buildStringSpecification(criteria.getClusterJobId(), Job_.clusterJobId)); } if (criteria.getStatus() != null) { specification = specification.and(buildSpecification(criteria.getStatus(), Job_.status)); } if (criteria.getCreatedBy() != null) { specification = specification.and(buildStringSpecification(criteria.getCreatedBy(), Job_.createdBy)); } if (criteria.getCreatedDate() != null) { specification = specification.and(buildRangeSpecification(criteria.getCreatedDate(), Job_.createdDate)); } if (criteria.getLastModifiedBy() != null) { specification = specification.and(buildStringSpecification(criteria.getLastModifiedBy(), Job_.lastModifiedBy)); } if (criteria.getLastModifiedDate() != null) { specification = specification.and(buildRangeSpecification(criteria.getLastModifiedDate(), Job_.lastModifiedDate)); } if (criteria.getBusinessId() != null) { specification = specification.and(buildSpecification(criteria.getBusinessId(), root -> root.join(Job_.business, JoinType.LEFT).get(Business_.id))); } if (criteria.getClusterId() != null) { specification = specification.and(buildSpecification(criteria.getClusterId(), root -> root.join(Job_.cluster, JoinType.LEFT).get(Cluster_.id))); } if (criteria.getSqlId() != null) { specification = specification.and(buildSpecification(criteria.getSqlId(), root -> root.join(Job_.sqls, JoinType.LEFT).get(JobSql_.id))); } } return specification; }
Example 20
Source File: CountryQueryService.java From Spring-5.0-Projects with MIT License | 4 votes |
/** * Function to convert CountryCriteria to a {@link Specification} */ private Specification<Country> createSpecification(CountryCriteria criteria) { Specification<Country> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Country_.id)); } if (criteria.getCode() != null) { specification = specification.and(buildStringSpecification(criteria.getCode(), Country_.code)); } if (criteria.getName() != null) { specification = specification.and(buildStringSpecification(criteria.getName(), Country_.name)); } if (criteria.getContinent() != null) { specification = specification.and(buildSpecification(criteria.getContinent(), Country_.continent)); } if (criteria.getRegion() != null) { specification = specification.and(buildStringSpecification(criteria.getRegion(), Country_.region)); } if (criteria.getSurfaceArea() != null) { specification = specification.and(buildRangeSpecification(criteria.getSurfaceArea(), Country_.surfaceArea)); } if (criteria.getPopulation() != null) { specification = specification.and(buildRangeSpecification(criteria.getPopulation(), Country_.population)); } if (criteria.getLifeExpectancy() != null) { specification = specification.and(buildRangeSpecification(criteria.getLifeExpectancy(), Country_.lifeExpectancy)); } if (criteria.getLocalName() != null) { specification = specification.and(buildStringSpecification(criteria.getLocalName(), Country_.localName)); } if (criteria.getGovernmentForm() != null) { specification = specification.and(buildStringSpecification(criteria.getGovernmentForm(), Country_.governmentForm)); } if (criteria.getCityId() != null) { specification = specification.and(buildSpecification(criteria.getCityId(), root -> root.join(Country_.cities, JoinType.LEFT).get(City_.id))); } if (criteria.getCountryLanguageId() != null) { specification = specification.and(buildSpecification(criteria.getCountryLanguageId(), root -> root.join(Country_.countryLanguages, JoinType.LEFT).get(CountryLanguage_.id))); } } return specification; }