Bonjour tout le monde,
Voilà je développe une application web, avec hibernate .
Je suis débutant en hibernate et mon problème c est que quand je fais un appel à la base de données ( Sql Server 2005) avec des jointures, j ai l'erreure suivante: could not resolve property.
Est ce que quelqu'un pourrait m'aider Thx ;)
voici la console d'erreurs:
Code:
Exception in thread "main" org.hibernate.QueryException: could not resolve property: code_agence of: com.WebApplication5.metier.Agence [from com.WebApplication5.metier.Interlocuteurs as interloc,com.WebApplication5.metier.Dossier as dos ,com.WebApplication5.metier.Agence as agen where agen.code_agence=dos.code_agence and dos.code_interlocuteur=interloc.code_interlocuteur and agen.code_agence like '%Int1']
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:44)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:38)
at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1358)
at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:279)
at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:386)
at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:566)
at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:241)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:188)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:94)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:90)
at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:728)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1216)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4041)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3525)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1687)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1687)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at com.WebApplication5.servlet.SearchInterlocuteur.rechercherI(SearchInterlocuteur.java:23)
at com.WebApplication5.Test.Test.main(Test.java:128)
Code:
package com.WebApplication5.servlet;
import java.util.Iterator;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import com.WebApplication5.connexion.HibernateUtil;
import com.WebApplication5.metier.Interlocuteurs;
public class SearchInterlocuteur {
public SearchInterlocuteur(){};
public Interlocuteurs rechercherI(String code){
Interlocuteurs inter=new Interlocuteurs();
Session sess = HibernateUtil.currentSession();
String hql = "from Interlocuteurs as interloc,Dossier as dos ,Agence as agen where agen.code_agence=dos.code_agence " +
"and dos.code_interlocuteur=interloc.code_interlocuteur " +
"and agen.code_agence like '%" + code + "'";
System.out.println(hql);
Query qr = sess.createQuery(hql);
List lst = qr.list();
Iterator it = lst.iterator();
if(qr== null){
return null;
}
else{
while (it.hasNext())
{
inter = (Interlocuteurs) it.next();
}
}
return inter;
}
}
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.WebApplication5.metier.Utilisateur" table="Utilisateur">
<id name="id" type="string" column="code_utilisateur">
<generator class="assigned"/>
</id>
<property name="codeDroit" column="code_droit" type="string" not-null="true"
length="50"/>
<property name="login" column="login" type="string" not-null="true"
length="50"/>
<property name="nomUtilisateur" column="nom_utilisateur" type="string" not-null="true"
length="50"/>
<property name="prenomUtilisateur" column="prenom_utilisateur" type="string" not-null="true"
length="50"/>
<property name="password" column="password" type="string" not-null="true"
length="50"/>
<property name="profil" column="profil" type="string" not-null="true"
length="50"/>
<property name="eMail" column="email" type="string" not-null="true"
length="50"/>
</class>
<class name="com.WebApplication5.metier.DroitAcces" table="Droit_acces">
<id name="idDroit" type="string" column="code_droit">
<generator class="assigned"/>
</id>
<property name="libelleDroit" column="liblelle_droit" type="string" not-null="true"
length="50"/>
<property name="description" column="description" type="string" not-null="true"
length="50"/>
</class>
<class name="com.WebApplication5.metier.Parametrage" table="Parametrage">
<id name="codeParametrage" type="string" column="code_parametrage">
<generator class="assigned"/>
</id>
<property name="repertoireEntree" column="repertoire_entree" type="string" not-null="true"
length="50"/>
<property name="repertoireSortie" column="repertoire_sortie" type="string" not-null="true"
length="50"/>
<property name="port" column="port" type="integer" not-null="true"
length="50"/>
</class>
<class name="com.WebApplication5.metier.Categorie" table="Parametrage">
<id name="codeCategorie" type="string" column="code_categorie">
<generator class="assigned"/>
</id>
<property name="libelleCategorie" column="libelle_categorie" type="string" not-null="true"
length="50"/>
</class>
<class name="com.WebApplication5.metier.Agence" table="Agence">
<id name="codeAgence" type="string" column="code_agence">
<generator class="assigned"/>
</id>
<property name="libelleAgence" column="libelle_agence" type="string" not-null="true"
length="50"/>
<property name="adresseAgence" column="adresse_agence" type="string" not-null="true"
length="50"/>
<property name="villeAgence" column="ville_agence" type="string" not-null="true"
length="50"/>
</class>
<class name="com.WebApplication5.metier.Documents" table="Documents">
<id name="codeDocument" type="string" column="code_document">
<generator class="assigned"/>
</id>
<property name="codePiece" column="code_piece" type="int" not-null="true"
length="50"/>
<property name="codeDossier" column="code_dossier" type="string" not-null="true"
length="50"/>
<property name="dateEnregistrement" column="date_enregistrement" type="date" not-null="true"
length="50"/>
</class>
<class name="com.WebApplication5.metier.Dossier" table="Dossier">
<id name="codeDossier" type="string" column="code_dossier">
<generator class="assigned"/>
</id>
<property name="CodeAgence" column="code_agence" type="string" not-null="true"
length="50"/>
<property name="CodeInterlocuteur" column="code_interlocuteur" type="string" not-null="true"
length="50"/>
<property name="codePartenaire" column="code_partenaire" type="string" not-null="true"
length="50"/>
<property name="nomClient" column="nom_client" type="string" not-null="true"
length="50"/>
<property name="montant" column="montant" type="float" not-null="true"
length="50"/>
<property name="dateCreation" column="date_creation" type="date" not-null="true"
length="50"/>
</class>
<class name="com.WebApplication5.metier.Interlocuteurs" table="Interlocuteurs">
<id name="codeInterlocuteur" type="string" column="code_interlocuteur">
<generator class="assigned"/>
</id>
<property name="nomInterlocuteur" column="nom_interlocuteur" type="string" not-null="true"
length="50"/>
<property name="prenomInterlocuteur" column="prenom_interlocuteur" type="string" not-null="true"
length="50"/>
<property name="telephone" column="telephone" type="string" not-null="true"
length="50"/>
<property name="email" column="email" type="string" not-null="true"
length="50"/>
</class>
<class name="com.WebApplication5.metier.Partenaire" table="Partenaire">
<id name="codePartenaire" type="string" column="code_partenaire">
<generator class="assigned"/>
</id>
<property name="codeCategorie" column="code_categorie" type="string" not-null="true"
length="50"/>
<property name="raisonSociale" column="raison_sociale" type="string" not-null="true"
length="50"/>
<property name="adressePartenaire" column="adresse_partenaire" type="string" not-null="true"
length="50"/>
<property name="villePartenaire" column="ville_partenaire" type="string" not-null="true"
length="50"/>
</class>
<class name="com.WebApplication5.metier.TypePiece" table="Type_piece">
<id name="codePiece" type="int" column="code_piece">
<generator class="assigned"/>
</id>
<property name="libellePiece" column="libelle_piece" type="string" not-null="true"
length="50"/>
</class>
</hibernate-mapping>