@Kleiton_A_Batista escreveu:
Boa noite, estou tentando realizar uma busca com jpa, estou com a seguinte query
String jpql = "Select m from Medicamento m where m.usuario_id = ?1";
mas da esse erro:
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.`classe medicamento
@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;
classe usuario
@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>();`
Mensagens: 2
Participantes: 2