Olá, ao fazer a consulta donforme descrito na aula, retorna o erro abaixo.
2020-11-23 12:43:06.432 INFO 7444 --- [nio-8085-exec-2] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
Hibernate: select clienteent0_.id as id1_0_, clienteent0_.cpf as cpf2_0_, clienteent0_.password as password3_0_, clienteent0_.titular as titular4_0_ from cliente_tb clienteent0_ where clienteent0_.cpf=? and clienteent0_.password=?
org.springframework.dao.IncorrectResultSizeDataAccessException: result returns more than one elements; nested exception is javax.persistence.NonUniqueResultException: result returns more than one elements
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:395)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:246)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:503)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:209)
O erro ocorre na pesquisa findByCpfAndPassword:
@Service
public class ClienteService {
...
public ClienteEntity getClienteByAuthorization(String authorization) {
String[] basicAuth = AuthUtil.getBasicAuth(authorization);
String cpf = basicAuth[0];
String password = basicAuth[1];
ClienteEntity clienteEntity = repository.findByCpfAndPassword(cpf, password);
return clienteEntity;
}
user: 01234567890 senha: senha123
Alguém sabe como resolver?