I am trying to write a JPQL query with a like clause:
LIKE \'%:code%\'
I would like to have code=4 and find
455
554
646
...
Use JpaRepository or CrudRepository as repository interface:
@Repository
public interface CustomerRepository extends JpaRepository {
@Query("SELECT t from Customer t where LOWER(t.name) LIKE %:name%")
public List findByName(@Param("name") String name);
}
@Service(value="customerService")
public class CustomerServiceImpl implements CustomerService {
private CustomerRepository customerRepository;
//...
@Override
public List pattern(String text) throws Exception {
return customerRepository.findByName(text.toLowerCase());
}
}