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

Hibernate Java Discussion :

[Hibernate 4.3] erreur de syntaxe HQL


Sujet :

Hibernate Java

  1. #1
    Membre averti
    Avatar de stc074
    Homme Profil pro
    Codeur du dimanche
    Inscrit en
    Janvier 2009
    Messages
    1 014
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Lozère (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Codeur du dimanche

    Informations forums :
    Inscription : Janvier 2009
    Messages : 1 014
    Points : 407
    Points
    407
    Billets dans le blog
    1
    Par défaut [Hibernate 4.3] erreur de syntaxe HQL
    Bonjour, j'essaie d'implémenter hibernate sur une de mes applis web, je l'ai fait via netbeans, par contre netbeans n'a pas voulu me générer mes Classes/fichier hbm avec son outil, j'ai donc tout fait à la main
    Je test une requête HQL
    J'ai cette erreur :
    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
    org.hibernate.exception.SQLGrammarException: could not extract ResultSet
    	at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:123)
    	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
    	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
    	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
    	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:89)
    	at org.hibernate.loader.Loader.getResultSet(Loader.java:2065)
    	at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1862)
    	at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838)
    	at org.hibernate.loader.Loader.doQuery(Loader.java:909)
    	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
    	at org.hibernate.loader.Loader.doList(Loader.java:2551)
    	at org.hibernate.loader.Loader.doList(Loader.java:2537)
    	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2367)
    	at org.hibernate.loader.Loader.list(Loader.java:2362)
    	at org.hibernate.hql.internal.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:939)
    	at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:229)
    	at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1260)
    	at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
    Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "from"
      Position*: 9
    	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
    	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)
    	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:559)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:302)
    	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:80)
    	... 15 more
    je pense pas que la syntaxe soit mauvaise, il doit y avoir un autre problème.
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
      <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
        <property name="hibernate.connection.url">jdbc:postgresql://127.0.0.1:5432/xxxxxxxxxx</property>
        <property name="hibernate.connection.username">xxxxxxxxxxxxx</property>
        <property name="hibernate.connection.password">xxxxxxxxxx</property>
        <property name="hibernate.show_sql">true</property>
        <property name="hibernate.current_session_context_class">thread</property>
        <property name="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory</property>
        <mapping class="hibernate.TUsers" package="hibernate" resource="hibernate/users.hbm.xml"/>
        <mapping class="hibernate.TActualIdAnchor" file="" jar="" package="hibernate" resource="hibernate/actual_id_anchor.hbm.xml"/>
        <mapping class="hibernate.TActualIdBacklink" file="" jar="" package="hibernate" resource="hibernate/actual_id_backlink.hbm.xml"/>
        <mapping class="hibernate.TAnchor" file="" jar="" package="hibernate" resource="hibernate/anchor.hbm.xml"/>
        <mapping class="hibernate.TCategory" file="" jar="" package="hibernate" resource="hibernate/category.hbm.xml"/>
        <mapping class="hibernate.TCategorySite" file="" jar="" package="hibernate" resource="hibernate/category_site.hbm.xml"/>
        <mapping class="hibernate.TCodeMdp" file="" jar="" package="hibernate" resource="hibernate/code_mdp.hbm.xml"/>
        <mapping class="hibernate.TSite" file="" jar="" package="hibernate" resource="hibernate/site.hbm.xml"/>
        <mapping/>
      </session-factory>
    </hibernate-configuration>
    TUsers.java
    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
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    package hibernate;
     
    import classes.SuperClass;
    import java.io.Serializable;
     
    /**
     *
     * @author marie
     */
    public class TUsers extends SuperClass implements Serializable {
     
        protected long id;
        protected String email;
        protected String mdp;
        protected String cookie_code;
     
        /**
         * @return the id
         */
        public long getId() {
            return id;
        }
     
        /**
         * @param id the id to set
         */
        public void setId(long id) {
            this.id = id;
        }
     
        /**
         * @return the email
         */
        public String getEmail() {
            return email;
        }
     
        /**
         * @param email the email to set
         */
        public void setEmail(String email) {
            this.email = email;
        }
     
        /**
         * @return the mdp
         */
        public String getMdp() {
            return mdp;
        }
     
        /**
         * @param mdp the mdp to set
         */
        public void setMdp(String mdp) {
            this.mdp = mdp;
        }
     
        /**
         * @return the cookie_code
         */
        public String getCookie_code() {
            return cookie_code;
        }
     
        /**
         * @param cookie_code the cookie_code to set
         */
        public void setCookie_code(String cookie_code) {
            this.cookie_code = cookie_code;
        }
    }
    users.hbm.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <?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="hibernate.TUsers" table="users">
            <id name="id" type="long">
                <generator class="increment"/>
            </id>
            <property name="email" column="email" type="string"/>
            <property name="mdp" column="mdp" type="string"/>
            <property name="cookie_code" column="cookie_code" type="string"/>
        </class>
    </hibernate-mapping>
    Merci !

  2. #2
    Membre averti
    Homme Profil pro
    Inscrit en
    Octobre 2011
    Messages
    250
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2011
    Messages : 250
    Points : 403
    Points
    403
    Par défaut
    Ce ne serait as plutôt "from TUsers" ?

  3. #3
    Membre averti
    Avatar de stc074
    Homme Profil pro
    Codeur du dimanche
    Inscrit en
    Janvier 2009
    Messages
    1 014
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Lozère (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Codeur du dimanche

    Informations forums :
    Inscription : Janvier 2009
    Messages : 1 014
    Points : 407
    Points
    407
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par NoClassDefFound Voir le message
    Ce ne serait as plutôt "from TUsers" ?
    Oui merci en effet (je débute j'ai vu une requêtes similaires sur le tuto netbeans mais je pensais qu'il fallait mettre le nom de la table).
    Merci !

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

Discussions similaires

  1. Requête HQL : erreur de syntaxe
    Par raf64flo dans le forum Hibernate
    Réponses: 0
    Dernier message: 26/04/2010, 18h47
  2. [Directives] Page blanche quand erreur de syntaxe
    Par syl2095 dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 12
    Dernier message: 17/02/2006, 15h15
  3. erreur de syntaxe en C++
    Par sergepmessa dans le forum C++
    Réponses: 6
    Dernier message: 11/03/2005, 18h15
  4. PHP SQL =>erreur de syntaxe (operateur absent)
    Par snipes dans le forum Langage SQL
    Réponses: 3
    Dernier message: 23/02/2005, 14h09
  5. erreur de syntaxe javascript dans ma page
    Par Oluha dans le forum Général JavaScript
    Réponses: 7
    Dernier message: 01/02/2005, 14h53

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