HQL est parti rejoindre: chemin attendu pour rejoindre
Je suis nouveau à Hibernate, et j'ai une question concernant les requêtes HQL Left join.
J'essaie de gauche joindre 2 tables, des patients et des soignants, et continue de recevoir "Chemin d'accès prévu pour les rejoindre!" erreur sur la deuxième table. Apprécier si quelqu'un peut aider sur ce problème!
Ici est la cartographie des 2 tableaux/classes:
patient.hbm.xmL:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.ccg.db.test">
<class name="patient" table="patient">
<id name="patientId" column="patientId" type="int">
<generator class="native"/>
</id>
<property name="patientName" type="string" >
<column name="patientName" />
</property>
<property name="providerId" type="string" >
<column name="provId" />
</property>
<many-to-one name="provider" column="providerId" class="provider" />
</class>
</hibernate-mapping>
provider.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.ccg.db.test">
<class name="provider" table="provider">
<id name="providerId" column="providerId">
<generator class="native" />
</id>
<property name="providerName" column="providerName" />
</class>
</hibernate-mapping>
pojo:
patient.java
package com.ccg.db.test;
import java.io.Serializable;
import java.util.List;
import org.hibernate.Session;
public class patient
implements Serializable
{
private int patientId;
private String patientName;
private String providerId; //foreign key to provider
private static final long serialVersionUID = 81073;
public static void load(Session session, List<String> values){
patient PatientInfo = new patient();
PatientInfo.setPatientId(Integer.parseInt(values.get(0)));
PatientInfo.setPatientName( values.get(1));
PatientInfo.setProviderId( values.get(2) );
session.save( PatientInfo );
}
/**
* @return the PatientId
*/
public int getPatientId() {
return patientId;
}
/**
* @param PatientId the PatientId to set
*/
public void setPatientId(int PatientId) {
this.patientId = PatientId;
}
/**
* @return the PatientName
*/
public String getPatientName() {
return this.patientName;
}
/**
* @param PatientName the PatientName to set
*/
public void setPatientName(String PatientName) {
this.patientName = PatientName;
}
/**
* @return the ProvId
*/
public String getProviderId() {
return this.providerId;
}
/**
* @param id the ProviderId to set
*/
public void setProviderId( String id ) {
this.providerId = id;
}
/**
* @return the ProvId
*/
public String getProvider() {
return this.providerId;
}
/**
* @param id the ProviderId to set
*/
public void setProvider( String id ) {
this.providerId = id;
}
/**
* @param args
*/
public static void main(String[] args) {
//TODO Auto-generated method stub
}
}
provider.java:
package com.ccg.db.test;
import java.io.Serializable;
import java.util.List;
import org.hibernate.Session;
public class provider
implements Serializable
{
private String providerId;
private String providerName;
//private int patientId;
//private int providerSpec;
private static final long serialVersionUID = 81073;
public static void load(Session session, List<String> values){
provider ProviderInfo = new provider();
ProviderInfo.setProviderId( values.get(0) );
ProviderInfo.setProviderName( values.get(1));
//ProviderInfo.setProviderSpec( Integer.parseInt(values.get(2)) );
session.save( ProviderInfo );
}
/**
* @return the ProviderName
*/
public String getProviderName() {
return providerName;
}
/**
* @param ProviderName the ProviderName to set
*/
public void setProviderName(String name) {
this.providerName = name;
}
/**
* @return the ProvId
*/
public String getProviderId() {
return this.providerId;
}
/**
* @param id the ProvId to set
*/
public void setProviderId( String id ) {
this.providerId = id;
}
/*
public int getPatientId() {
return this.patientId;
}
public void setPatientId( int id ) {
this.patientId = id;
}
*/
/**
* @param args
*/
public static void main(String[] args) {
//TODO Auto-generated method stub
}
}
Ici est la gauche de la requête de jointure:
select
pat.patientId, pat.patientName
from
patient as pat
left join
provider as pro
where
pat.providerId = pro.providerId
et voici le résultat:
0:50:08,479 INFO requête:156 - Query = outerJoin 10:50:08,479 INFO requête:157 - sélectionnez pat.patientId, pat.patientName à partir de patient comme pat left join fournisseur de pro où pat.providerId = pro.providerId 10:50:08,698 d'ERREUR de l'ANALYSEUR:33 - Chemin prévu pour rejoindre! 10:50:08,698 d'ERREUR de l'ANALYSEUR:33 - chemin d'accès non Valide: 'pro.providerId' 10:50:08,698 d'ERREUR de l'ANALYSEUR:33 - droite opérande d'un opérateur binaire est nulle 10:50:08,698 ERREUR de requête:184 - Problème de la génération de la requête. org.mise en veille prolongée.hql.ast.QuerySyntaxException: Chemin d'accès prévu pour les rejoindre! [sélectionnez pat.patientId, pat.patientName à partir de com.la gcc.db.test.patient comme pat left join fournisseur de pro où pat.providerId = pro.providerId ] au org.mise en veille prolongée.hql.ast.QuerySyntaxException.convertir(QuerySyntaxException.java:31) au org.mise en veille prolongée.hql.ast.QuerySyntaxException.convertir(QuerySyntaxException.java:24) au org.mise en veille prolongée.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59) au org.mise en veille prolongée.hql.ast.QueryTranslatorImpl.analyser(QueryTranslatorImpl.java:235) au org.mise en veille prolongée.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160) au org.mise en veille prolongée.hql.ast.QueryTranslatorImpl.compiler(QueryTranslatorImpl.java:111) au org.mise en veille prolongée.moteur.de la requête.HQLQueryPlan.(HQLQueryPlan.java:77) au org.mise en veille prolongée.moteur.de la requête.HQLQueryPlan.(HQLQueryPlan.java:56) au org.mise en veille prolongée.moteur.de la requête.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72) au org.mise en veille prolongée.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133) au org.mise en veille prolongée.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112) au org.mise en veille prolongée.impl.SessionImpl.createQuery(SessionImpl.java:1623) au com.la gcc.db.de la requête.QueryManager.requête(QueryManager.java:163) au com.la gcc.db.de la requête.QueryManager.requête(QueryManager.java:139) au com.la gcc.db.de la requête.QueryManager.principale(QueryManager.java:80)
source d'informationauteur
Vous devez vous connecter pour publier un commentaire.
Votre patient a une référence au fournisseur, et a également l'identificateur du fournisseur en tant que propriété. Je serais probablement se débarrasser de l'identité des fournisseurs de biens sur le patient et juste avoir la référence du fournisseur. Ensuite, votre requête doit être quelque chose comme ça.
Rejoindre, vous avez besoin de l'association chemin d'accès à partir de votre patient à votre fournisseur, qui dans ce cas est pat.fournisseur de. Ensuite, hibernate utilisera automatiquement la "colonne" spécifié dans le many-to-one mapping pour rejoindre dans le fournisseur de la table. Dans votre cas, la jointure ne fait pas beaucoup de sens, parce que vous n'êtes pas à l'interrogation sur toutes les propriétés du fournisseur, donc quelque chose comme cela pourrait faire plus de sens
Là, vous êtes en mesure de filtrer votre liste de patients pour les patients du nom de John qui ont en soins de Santé Unis en tant que fournisseur.