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 :

SQL Server et Hibernate problème de récupération des données


Sujet :

Hibernate Java

  1. #1
    Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juillet 2012
    Messages
    171
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2012
    Messages : 171
    Points : 56
    Points
    56
    Par défaut SQL Server et Hibernate problème de récupération des données
    Bonjour,
    Je suis en train de tester une application (simple affichage à partir d'une base de données SQL Server), j'utilise Hibernate, et jtds comme driver.
    Lorsque j’exécute mon programme j'obtiens l'exception suivante :


    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
    73
    74
    75
    76
     
     
     
    Infos: building session factory
    oct. 20, 2014 11:30:15 PM org.hibernate.impl.SessionFactoryObjectFactory addInstance
    Infos: Not binding factory to JNDI, no JNDI name configured
    oct. 20, 2014 11:30:15 PM org.hibernate.type.NullableType nullSafeGet
    Infos: could not read column value from result set: M23_0_0_; Value 4110702013007059E cannot be converted to INTEGER.
    oct. 20, 2014 11:30:16 PM org.hibernate.util.JDBCExceptionReporter logExceptions
    Avertissement: SQL Error: 0, SQLState: 22000
    oct. 20, 2014 11:30:16 PM org.hibernate.util.JDBCExceptionReporter logExceptions
    Grave: Value 4110702013007059E cannot be converted to INTEGER.
    Exception in thread "AWT-EventQueue-0" org.hibernate.exception.DataException: could not execute query
    	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:102)
    	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    	at org.hibernate.loader.Loader.doList(Loader.java:2452)
    	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2192)
    	at org.hibernate.loader.Loader.list(Loader.java:2187)
    	at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
    	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1706)
    	at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
    	at com.pchalle.classeMetier.MDossier.afficherDossiersParExerciceEtTypeOp(MDossier.java:340)
    	at com.pchalle.fenetre.AccueilFen$2.actionPerformed(AccueilFen.java:75)
    	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    	at java.awt.Component.processMouseEvent(Unknown Source)
    	at javax.swing.JComponent.processMouseEvent(Unknown Source)
    	at java.awt.Component.processEvent(Unknown Source)
    	at java.awt.Container.processEvent(Unknown Source)
    	at java.awt.Component.dispatchEventImpl(Unknown Source)
    	at java.awt.Container.dispatchEventImpl(Unknown Source)
    	at java.awt.Component.dispatchEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    	at java.awt.Container.dispatchEventImpl(Unknown Source)
    	at java.awt.Window.dispatchEventImpl(Unknown Source)
    	at java.awt.Component.dispatchEvent(Unknown Source)
    	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    	at java.awt.EventQueue.access$200(Unknown Source)
    	at java.awt.EventQueue$3.run(Unknown Source)
    	at java.awt.EventQueue$3.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue$4.run(Unknown Source)
    	at java.awt.EventQueue$4.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: java.sql.SQLException: Value 4110702013007059E cannot be converted to INTEGER.
    	at net.sourceforge.jtds.jdbc.Support.convert(Support.java:752)
    	at net.sourceforge.jtds.jdbc.JtdsResultSet.getInt(JtdsResultSet.java:675)
    	at net.sourceforge.jtds.jdbc.JtdsResultSet.getInt(JtdsResultSet.java:1002)
    	at org.hibernate.type.IntegerType.get(IntegerType.java:51)
    	at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:186)
    	at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:175)
    	at org.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:158)
    	at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2267)
    	at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1443)
    	at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1371)
    	at org.hibernate.loader.Loader.getRow(Loader.java:1271)
    	at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:619)
    	at org.hibernate.loader.Loader.doQuery(Loader.java:745)
    	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
    	at org.hibernate.loader.Loader.doList(Loader.java:2449)
    	... 43 more
    En googlant, j'ai pu comprendre que peut être, il y a un problème au niveau des types des variables.
    Sachant que j'ai utilisé la Reverse Engineering, pour générer les classes métiers (et par la suite le types des variables est géré par Hibernate), avez vous une idée de la source du problème.
    Merci

  2. #2
    Modérateur
    Avatar de kolodz
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2008
    Messages
    2 211
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 211
    Points : 8 316
    Points
    8 316
    Billets dans le blog
    52
    Par défaut
    Infos: could not read column value from result set: M23_0_0_; Value 4110702013007059E cannot be converted to INTEGER.
    Avertissement: SQL Error: 0, SQLState: 22000
    Grave: Value 4110702013007059E cannot be converted to INTEGER.
    Il y a une valeur dans ta base de donnée qui est "4110702013007059E" qui se trouve dans une colonne considéré comme devant être un integer en Java. (D'après ton mapping)
    Or ce n'est pas le cas (à cause du E)...
    Du coup, Hibernate lance une exception, car il a une corruption des données qu'il ne sais pas traiter.
    A toi de savoir pourquoi cette valeur s'est retrouvé dans cette colonne.

    Cordialement,
    Patrick Kolodziejczyk.
    Si une réponse vous a été utile pensez à
    Si vous avez eu la réponse à votre question, marquez votre discussion
    Pensez aux FAQs et aux tutoriels et cours.

  3. #3
    Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juillet 2012
    Messages
    171
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2012
    Messages : 171
    Points : 56
    Points
    56
    Par défaut
    Effectivement, votre réponse était très utile.
    Le problème est du au fait que la clé étrangère d'une table est déclaré une chaîne de caractère, alors que la configuration consiste à la considérer comme un Inetger.

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

Discussions similaires

  1. Réponses: 1
    Dernier message: 14/10/2014, 13h19
  2. Réponses: 4
    Dernier message: 02/03/2010, 16h09
  3. Réponses: 31
    Dernier message: 27/07/2006, 13h51
  4. Réponses: 22
    Dernier message: 05/07/2006, 15h21
  5. Réponses: 16
    Dernier message: 14/04/2006, 18h38

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