Difference between Query keywords Containing, IsContaining, Contains, Like in Spring Data JPA

Viewed 583

What is the difference between Query keywords Containing, IsContaining, Contains, Like in Spring Data?

List<T> findBy...Containing();
List<T> findBy...Contains();
List<T> findBy...IsContaining();
List<T> findBy...Like();
1 Answers

IsContaining, Containing and Contains are almost same.

For example,

List<Employee> findByNameContaining(String name);
List<Employee> findByNameContains(String name);
List<Employee> findByNameIsContaining(String name);

For all above methods spring data will create query with LIKE clause where value will be wrapped in % as shown in below query when Name = ABC

SELECT * FROM Employee WHERE Name LIKE '%ABC%'

Whereas in Like method user need to explicitly add the wildcards.

For example,

List<T> findByNameLike(String name);

For above method spring data will create query similar to below query when Name = ABC

SELECT * FROM Employee WHERE Name LIKE 'ABC'
Related