For your case, you can directly use JPA methods. That is like bellow:
Containing: select ... like %:username%
List<User> findByUsernameContainingIgnoreCase(String username);
here, IgnoreCase will help you to search item with ignoring the case.
Here are some related methods:
Like findByFirstnameLike
… where x.firstname like ?1
StartingWith findByFirstnameStartingWith
… where x.firstname like ?1 (parameter bound with appended %)
EndingWith findByFirstnameEndingWith
… where x.firstname like ?1 (parameter bound with prepended %)
Containing findByFirstnameContaining
… where x.firstname like ?1 (parameter bound wrapped in %)
More info , view this link and this link
Hope this will help you :)