I'm trying to make a case sensitive query in a repository that extends JpaRepository, in a Spring Boot 2 project with Spring Data JPA.
It's supposed that if I don't use IgnoreCase, the query should be case sensitive, but it doesn't occur.
Snippet:
log.info("Received name: " + name);
Player player = playerRepository.findByName(name).orElseThrow(()-> new NonExistingPlayerNameException(name));
log.info("Repository player name: " + player.getName());
Console result:
2020-03-19 13:05:02.831 INFO 13739 [...].controllers.PlayerController : Received name: peter
2020-03-19 13:05:02.884 INFO 13739 [...].controllers.PlayerController : Repository player name: Peter
As you can see, the query is case insensitive, but I want it case sensitive.
Am I doing anything wrong? How can I make the query case sensitive?
As a workaround, I can make the check after I receive the object and act in consequence, but I expected the query to be case sensitive.
Thanks in advance,
Carlos.
Edit:
Thanks for the answers and sorry about the missed information.
I'm using a MySQL database (mysql Ver 8.0.19-0ubuntu0.19.10.3 for Linux on x86_64 ((Ubuntu))) in a Ubuntu Desktop 19.10.
I'm sorry but I don't know how to log the actual query that gets executed.
What I can see is that the database allows me to save a register with upper and lower case, I can have a row with field name 'Peter' and another one with name 'peter'. I mean, the database seems that doesn't change the data to store it.
I will take a look at the answer about MSSQL Server.
Thank you,
Carlos.