接合2代表我有這樣的錯誤的createQuery在JPA
The collection-valued path 'c.medecin' cannot be resolved to a valid association field
The state field path 'm.id' cannot be resolved to a valid type.
當我執行這個請求
createQuery("select c from Creneaux c join c.medecin m where m.id=:idMedecin").setParameter("idMedecin", medecin.getId());
我使用這2個表:醫師無(ID)和CRENEAUX(ID,ID_MEDECIN)
@Entity
@Table(name = "medecins")
@XmlRootElement
public class Medecins implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ID")
private Long id;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "medecin"/*"idMedecin"*/)
private transient List<Creneaux> creneauxList;
}
和
@Entity
@Table(name = "creneaux")
public class Creneaux implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ID")
private Long id;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="ID_MEDECIN")
private transient Medecins medecin;
@Column(name = "ID_MEDECIN")
private BigInteger idMedecin;
我從JPA開始,所以我不確定所有的代碼。我認爲查詢是正確的,但我不知道如何註釋實體以使查詢有效。 感謝