【发布时间】:2015-12-18 04:16:50
【问题描述】:
我有由 ManyToMany 关联生成的 mysql 表。这个表是user_carrier,但是当我运行这个查询时:
select c from client c
inner join c.utilisateur_transportcat utc
inner join utc.transportcat tc
inner join tc.transport t
where t.intitule like 'byroad'
我收到此错误:
:table user_carrier 没有映射
我认为这是因为它不是一个类,它只是一个由 ManyToMany 关联生成的表关联,但我该怎么办?
类载体是:
@Entity
@Table(name="TransportCat")
public class TransportCat {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer IdTransportCat;
private String Intitule;
@Lob @Basic(fetch=FetchType.LAZY, optional=false)
private String Description;
private String iconImage;
private boolean Statut;
@ManyToOne
@JoinColumn(name="IdTransport")
private Transport transport;
@ManyToMany(mappedBy="listTransportTrCat")
private List<Client> listClient=new ArrayList<Client>();
表用户是:
@Entity
@DiscriminatorValue(value="client")
public class Client extends Utilisateur{
//champs client privé
private String Nom;
private String Prenom;
//question
@OneToMany(mappedBy="client",fetch=FetchType.LAZY,cascade=CascadeType.ALL,orphanRemoval=true)
private List<Question> listeQuestion=new ArrayList<Question>();
//liste des abonnements d'un utilisateur
@OneToMany(mappedBy="pk.client",fetch=FetchType.LAZY,orphanRemoval=true)
private List<Commission_Client> listeCommissionClient=new ArrayList<Commission_Client>();
/*@OneToMany(mappedBy="pk.client",fetch=FetchType.LAZY)
private List<Abon_Comm_Client> listeAbonnement=new ArrayList<Abon_Comm_Client>();*/
//liste des factures
@OneToMany(mappedBy="client",fetch=FetchType.LAZY)
private List<Facture> listeFacture=new ArrayList<Facture>();
//geolocalisation
@OneToMany(mappedBy="client")
private List<geolocalisation> listeGeolocalisations=new ArrayList<geolocalisation>();
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="IdVille_usr")
private Ville Ville_Utilisateur;
//déclaration
@OneToMany(mappedBy="Transporteur",fetch=FetchType.LAZY)
private List<Declaration> listeDeclaration=new ArrayList<Declaration>();
//clients
@OneToMany(mappedBy="client",fetch=FetchType.LAZY)
private List<Paiement> listePaiement=new ArrayList<Paiement>();
private String CodePost_usr;
private String Rue_usr;
private String Telephone_usr;
private String Mobile_usr;
private Long CID;
private Date dateCr;
//commentaire
@Lob @Basic(fetch=FetchType.LAZY, optional=false)
private String Comment;
//champs pour un client proffessionnel
public List<Paiement> getListePaiement() {
return listePaiement;
}
public void setListePaiement(List<Paiement> listePaiement) {
this.listePaiement = listePaiement;
}
private String position;
//proffessionnelle ou priv�
private String Type_client;
//Transporteur ou expediteur
private String TranExp;
//� propos de la soci�t�
private String Nom_Societe;
private String Details_Societe;
@ManyToOne
@JoinColumn(name="id")
private Langue langue;
@ManyToOne
@JoinColumn(name="idIndustrie")
private Industrie industrie;
//type de service local national international pour un transporteur
private String ServiceType;
//ville societe
@ManyToOne
@JoinColumn(name="IdVille_Societe")
private Ville ville_Societe;
private String CodePost_Societe;
private String Rue_Societe;
private String Telephone_societe;
private String Fax;
private String Organization_Number;
@OneToMany(mappedBy="Client",cascade=CascadeType.ALL,orphanRemoval=true,fetch=FetchType.LAZY)
List<GLN> list_GLN=new ArrayList<GLN>();
//assurance
private String Assurance_Societe;
private String Assurance_Adresse;
private String Assurance_Policy_Number;
private String Assurance_montant;
private String Assurance_Contact_phone;
private Date Asssurance_Expiration;
@ManyToOne
@JoinColumn(name="idVille_Postal")
private Ville ville_postal;
private String CodePost_Postal;
private String Rue_Postal;
//Expediteur
private String Web_Site;
//Transporteur
@ManyToMany(cascade=CascadeType.ALL)
private List<TransportCat> listTransportTrCat=new ArrayList<TransportCat>();
在类中,用户是类中的最后一个关联,在该类中你有多对多,并且在类载体中是最后一个关联 并感谢您的帮助
【问题讨论】:
-
发布您的实体和您的真实代码。 JPQL 不关心表。它使用实体及其关联。不要假设 JPQL 与 SQL 是一回事。不是。
-
我正要回答,在编辑您的问题以使代码可读之后,但您刚刚删除了您的代码。叹息。
-
我现在编辑了,如果你能帮助我,请
标签: mysql jboss7.x jpql ejb-3.1