I am trying to perform a search with jpa, I have the following query:
String jpql = "Select m from Medicamento m where m.usuario_id = ?1";
But this error occurs:
Exception in thread "main" java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Problem compiling [Select m from Medicamento m where m.usuario_id = ?1].
[34, 46] The state field path 'm.usuario_id' cannot be resolved to a valid type.
drug class
@Entity
public class Medicamento implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String codigoBarras;
private String nomeProduto;
private String principioAtivo;
private String apresentacao;
private String laboratorio;
private String classeTerapeutica;
user class
@Entity()
public class Usuario implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private Integer idUsuario;
private Integer idade;
private String nome;
private String email;
private String senha;
@JoinColumn(name = "usuario_id")
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private List<Medicamento> medicamentos = new ArrayList<Medicamento>();