Hello guys suppose i have entity called Student this entity has its own fields firstName, lastName idNumber etc… and also it has relation with @ManyToOne Class entity and @ManyToMane with Set roles. inside Roles entity there is relation with Permission @ManyToOne and inside Skill there is relation with SkillTypealso many to one. Now question is how i create specification implementation for my Student class probably need all fieleds and Long id of roleId, also skillId, and SkillTypeId. and how should i impelement
@Override
public Predicate toPredicate(Root root, CriteriaQuery<?> query, CriteriaBuilder cb) ?
for direct fieleds i think
predicates.add(cb.like(cb.lower(root.get(“firstName”)), “%” + searchQuery.getFirstName().toLowerCase() + “%”));
but what if i want to search with skillsTypeId? probably
if (searchQuery.getSkillTypeId() != null && !searchQuery.getSkillTypeId().isEmpty()) {
predicates.add(root.get(“roles”).get(“skills”).get(“skillsType”).get(“id”).in(searchQuery.getPermTypeIds()));
}
or should i use .join instead of directly .get?