Skip to content

Instantly share code, notes, and snippets.

@pavankjadda
Created January 12, 2021 06:40
Show Gist options
  • Save pavankjadda/2fe657637ab3c06f692a4ad23108fc53 to your computer and use it in GitHub Desktop.
Save pavankjadda/2fe657637ab3c06f692a4ad23108fc53 to your computer and use it in GitHub Desktop.
Multi Column Search - Query.md
public interface EmployeeProjectViewRepository extends JpaRepository<EmployeeProjectView, Long>,  JpaSpecificationExecutor<EmployeeProjectView>
{
	@Query(value = "SELECT e FROM EmployeeProjectView as e WHERE e.employeeId=:employeeId and (:inputString is null or e.lastName like %:inputString% ) and " +
			"(:inputString is null or e.firstName like %:inputString%) and (:inputString is null or concat(e.projectId,'') like %:inputString%) and " +
			" (:inputString is null or e.projectName like %:inputString%) and  (:inputString is null or concat(e.projectBudget,'') like %:inputString%) and "+
			" (:inputString is null or e.projectLocation like %:inputString%)"
	)
	Page<EmployeeProjectView> findAllByInputString(Long employeeId, String inputString, Pageable pageable);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment