You can add field annotated with @Formula to the entity
@Formula("concat(fam, name, otch)")
private String fullName;
where fam
, name
, otch
are columns names.
And use it this way
Predicate predicate = criteriaBuilder.like(teacherRoot.get("fullName"),"%" + str + "%");