I would like to know if it is possible to create a JPA without using the @Query annotation to get the results from an atribute of the object inside the object I am querying.
I am able to to `List findAllById(Long id) just fine, but what I would like to know is if it's possible to make a similar query that will look for the atribute of an object inside that class, example of my domain as follows:
public class OcorrenciaParticipante
@Id
@Column(name = "cod_ocorrencia_participante")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long codigo;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "cod_ocorrencia", referencedColumnName = "cod_ocorrencia")
private Ocorrencia ocorrencia;
public class Ocorrencia
@Id
@Column(name = "cod_ocorrencia")
private Long codigo;
What I want is to write something like List<OcorrenciaParticipante> findAllByOcorrencia
to get a list of OcorrenciaParticipante using the codigo
atribute from the Ocorrencia class.
When I do the above, and call my endpoint passing the value of variable codigo, I get the exception:
java.lang.IllegalArgumentException: Parameter value [1] did not match expected type [project.model.oc.Ocorrencia (n/a)]
I have tried some things using the information from here https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repository-query-keywords
Is that possible?