IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Frameworks Web Java Discussion :

Hibernate HQL - Erreur : DOT node with no left-hand-side


Sujet :

Frameworks Web Java

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2008
    Messages : 26
    Points : 30
    Points
    30
    Par défaut Hibernate HQL - Erreur : DOT node with no left-hand-side
    Bonjour,

    J'ai 2 tables ds ma base, donc 2 classes:

    - User
    - Societe

    Pour povoir se connecter à mon site, il faut avoir login, pwd et société dans les bases.
    La requête HQL :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    from org.hibernate.tutorial.domain.User
     inner join org.hibernate.tutorial.domain.Societe 
    where login = :login and pwd = :pwd and Societe.societeName = :societeName
    me donne:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    [WARN] Exception while dispatching incoming RPC call
    com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public 
    abstract java.lang.String com.hibernate_test.client.GreetingService.Connect
    (java.lang.String,java.lang.String,java.lang.String)
     throws java.lang.IllegalArgumentException'
     threw an unexpected exception: java.lang.IllegalStateException:
     DOT node with no left-hand-side!
    Si qq'un voit ce que signifie cette erreur, merci de m'en faire part !

  2. #2
    Expert confirmé
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 274
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 274
    Points : 4 141
    Points
    4 141
    Par défaut
    Je ne connais pas ton mapping, mais ta jointure me semble erronée.
    J'aurais plutôt écrit quelque chose comme cela :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    from org.hibernate.tutorial.domain.User user
     inner join user.Societe societe
    where user.login = :login and user.pwd = :pwd and societe.societeName = :societeName

  3. #3
    Expert confirmé
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 274
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 274
    Points : 4 141
    Points
    4 141
    Par défaut
    Voire même:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    from org.hibernate.tutorial.domain.User user
    where user.login = :login and user.pwd = :pwd and user.societe.societeName = :societeName

  4. #4
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2008
    Messages : 26
    Points : 30
    Points
    30
    Par défaut
    Avec ta 2ème requete, j'obtient ceci:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    could not resolve property: societe of: org.hibernate.tutorial.domain.User [from org.hibernate.tutorial.domain.User user where user.login = :login and user.pwd = :pwd and user.societe.societeName = :societeName]
    et pour info, si je mets:
    ça marche.
    Par contre, si je mets:
    j'obtiens:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    org.hibernate.tutorial.domain.Societe cannot be cast to org.hibernate.tutorial.domain.User
    Donc ça viens peut-être d'ailleurs.
    Voici mes classes:

    Classe Societe
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    package org.hibernate.tutorial.domain;
     
    @SuppressWarnings("serial")
     
    public class Societe implements java.io.Serializable {
     
    	private Integer societeId;
    	private String societeName;
     
    	public Societe() {
    	}
     
    	public Societe(String societeName) {
    		this.societeName = societeName;
    	}
     
    	public Integer getSocieteId() {
    		return this.societeId;
    	}
     
    	public void setSocieteId(Integer societeId) {
    		this.societeId = societeId;
    	}
     
    	public String getSocieteName() {
    		return societeName;
    	}
     
    	public void setSocieteName(String societeName) {
    		this.societeName = societeName;
    	}
    }
    Classe User
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    package org.hibernate.tutorial.domain;
     
    @SuppressWarnings("serial")
     
    public class User implements java.io.Serializable {
     
    	private Integer userId;
    	private String login;
    	private String pwd;
    	private Integer societeId;
     
    	public User() {
    	}
     
    	public User(String login) {
    		this.login = login;
    	}
     
    	public Integer getUserId() {
    		return this.userId;
    	}
     
    	public void setUserId(Integer userId) {
    		this.userId = userId;
    	}
     
    	public String getLogin() {
    		return login;
    	}
     
    	public void setLogin(String login) {
    		this.login = login;
    	}
     
    	public String getPwd() {
    		return pwd;
    	}
     
    	public void setPwd(String pwd) {
    		this.pwd = pwd;
    	}
     
     
    	public Integer getSocieteId() {
    		return societeId;
    	}
     
    	public void setSocieteId(Integer societeId) {
    		this.societeId = societeId;
    	}
    }

    Dans ma BD, je mets le SOCIETE_ID dans les 2 tables, mais est-ce que je dois mettre dans les 2 classes (comme j'ai fait) le paramètre societeId et les fonctions getSocieteId() et setSocieteId() ?

    Merci bcp!

    Si ça peut t'aider, voici mon "hibernate.cfg.xml" :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
     
    	<session-factory>
     
    		<!-- Database connection settings -->
    		<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    		<property name="connection.password"></property>
    		<property name="connection.url">jdbc:mysql://127.0.0.1/tipi_j2ee_v1</property>
    		<property name="connection.username">root</property>
    		<!-- SQL dialect -->
    		<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
     
    		<!-- Disable the second-level cache -->
    		<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
    		<property name="current_session_context_class">thread</property>
     
    		<!-- configuration pool via c3p0--> 
    		<property name="c3p0.acquire_increment">1</property> 
    		<property name="c3p0.idle_test_period">100</property> <!-- seconds --> 
    		<property name="c3p0.max_size">100</property> 
    		<property name="c3p0.max_statements">0</property> 
    		<property name="c3p0.min_size">10</property> 
    		<property name="c3p0.timeout">100</property> <!-- seconds --> 
    		<!-- DEPRECATED very expensive property name="c3p0.validate>-->
     
    		<!-- Echo all executed SQL to stdout -->
    		<property name="show_sql">true</property>
    		<mapping resource="org/hibernate/tutorial/domain/User.hbm.xml"/>
    		<mapping resource="org/hibernate/tutorial/domain/Societe.hbm.xml"/>
    	</session-factory>
     
    </hibernate-configuration>

  5. #5
    Expert confirmé
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 274
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 274
    Points : 4 141
    Points
    4 141
    Par défaut
    Ton mapping n'est pas bon.
    Dans ta classe User, remplace:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    private Integer societeId;
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    private Societe societe;
    Pour les relations, on ne manipule pas les id mais les objets directement.

  6. #6
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2008
    Messages : 26
    Points : 30
    Points
    30
    Par défaut
    Et je suppose donc que je doit mettre :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    	public Societe getSociete() {
    		return societe;
    	}
     
    	public void setSociete(Societe societe) {
    		this.societe = societe;
    	}
    L'erreur qui se produisait qd je mettait la requête "from Societe" était dû à autre chose.
    Mais maintenant, avec ta requête, j'ai :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     org.hibernate.QueryException: could not resolve property: societeName 
    of: org.hibernate.tutorial.domain.User [from org.hibernate.tutorial.domain.User user
     where user.login = :login and user.pwd = :pwd
     and user.societe.societeName = :societeName]

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 15/05/2011, 16h33
  2. Réponses: 2
    Dernier message: 03/05/2010, 21h13
  3. [Hibernate 3][HQL] erreur de Delete
    Par CharlSka dans le forum Hibernate
    Réponses: 5
    Dernier message: 20/04/2007, 16h02
  4. [Hibernate] Proxy erreur
    Par DarkNagash dans le forum Hibernate
    Réponses: 2
    Dernier message: 05/08/2005, 11h32
  5. Question facile, erreur bizzare lors d'un Left, Top
    Par SpiderAlpha dans le forum C++Builder
    Réponses: 4
    Dernier message: 05/05/2004, 12h56

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo