Hi, I am using Spring Data JPA 1.3.0, I have a repository: CompanyRepository and a service CompanyService.
This is my problem, I am using the query generated from method name approach in one of my repository methods:
And I am calling it from my service like this:Code:findById_CompanyAndId_NameAndStatus(BigDecimal company, String name, String status);
I am expecting the method to return a result only if the three fields are equal to the provided values, it works properly and returns the information for the company when it finds it in the db.Code:companyRepository.findById_CompanyAndId_NameAndStatus(new BigDecimal(1), "COMP", "A");
The problem is that it is also returning the same result when the first characters match, for example the following calls will get the same result:
second and third should not return any result as they don't exist in the db, but I don't know why they return the same result than the first one that does exist. If I add a character at the beginning then it wont get anything as expected for example:Code:companyRepository.findById_CompanyAndId_NameAndStatus(new BigDecimal(1), "COMP", "A"); companyRepository.findById_CompanyAndId_NameAndStatus(new BigDecimal(1), "COMPALL", "A"); companyRepository.findById_CompanyAndId_NameAndStatus(new BigDecimal(1), "COMP2", "A");
does not return any result because it does not exist, that is correct.Code:companyRepository.findById_CompanyAndId_NameAndStatus(new BigDecimal(1), "aCOMP", "A");
What can be the problem?


Reply With Quote
