0
I’m having a doubt when creating a findBy using jpa with atríbuto of a nested object, the classes are:
public class Livro {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String titulo;
@ManyToOne
private Usuario usuario;
and
public class Usuario {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String nome;
private String email;
I need to return the books of a particular user by providing his email.
I tested using these methods in Restpository but it didn’t work:
List<Livro> findByLivro_Usuario_Email(String email);
List<Livro> findByLivroUsuario_Email(String email);
Do you have any suggestions of what might be?
I believe what you are looking for is a findByUsuarioEmail , but in the books Repository
– Lucas Miranda
You’re right, I made the correction here and it worked, it went like this:

@Repository
public interface LivroRepository extends JpaRepository<Livro, Long> {
 List<Livro> findByUsuarioEmail(String email);
}

Thank you very much– Matheus C O Santos