fixed search on author, but it is very slow

This commit is contained in:
fred-fri 2012-05-31 17:34:15 +09:00
parent 5ace37e947
commit 983e143579

@ -55,7 +55,7 @@ public class ProjectServiceImpl extends AbstractQueryService<Project, Long> impl
@Override
public Page<Project> find(String filterString, Date fromDate, Date toDate, Pageable pageable) {
return projectRepo.findAll((titleContains(filterString).or(headSupervisorFirstNameContains(filterString).or(headSupervisorLastNameContains(filterString)))).and(projectCreatedAfter(fromDate)).and(projectCreatedBefore(toDate)), pageable);
return projectRepo.findAll((authorsFirstNameContains(filterString).or(authorsLastNameContains(filterString)).or(titleContains(filterString)).or(headSupervisorFirstNameContains(filterString).or(headSupervisorLastNameContains(filterString)))).and(projectCreatedAfter(fromDate)).and(projectCreatedBefore(toDate)), pageable);
}
@Override
@ -65,7 +65,7 @@ public class ProjectServiceImpl extends AbstractQueryService<Project, Long> impl
@Override
public Long count(String filterString, Date fromDate, Date toDate) {
return projectRepo.count((titleContains(filterString).or(headSupervisorFirstNameContains(filterString).or(headSupervisorLastNameContains(filterString)))).and(projectCreatedAfter(fromDate)).and(projectCreatedBefore(toDate)));
return projectRepo.count((authorsFirstNameContains(filterString).or(authorsLastNameContains(filterString)).or(titleContains(filterString)).or(headSupervisorFirstNameContains(filterString).or(headSupervisorLastNameContains(filterString)))).and(projectCreatedAfter(fromDate)).and(projectCreatedBefore(toDate)));
}
@Override
@ -123,7 +123,16 @@ public class ProjectServiceImpl extends AbstractQueryService<Project, Long> impl
}
//Boolean expressionns for building predicate queries
//Boolean expressions for building predicate queries
//the below two authorXnamecontains methods make the search very slow.
private BooleanExpression authorsFirstNameContains(String searchTerm){
return QProject.project.projectParticipants.any().user.firstName.containsIgnoreCase(searchTerm);
}
private BooleanExpression authorsLastNameContains(String searchTerm){
return QProject.project.projectParticipants.any().user.lastName.containsIgnoreCase(searchTerm);
}
private BooleanExpression isProjectFollower(List<ProjectFollower> pf) {
return QProject.project.projectFollowers.any().in(pf);