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 :

Problème avec la date


Sujet :

Hibernate Java

  1. #1
    Membre actif Avatar de aljessy
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2010
    Messages
    319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2010
    Messages : 319
    Points : 200
    Points
    200
    Par défaut Problème avec la date
    Bonjour, j'utilise gregorian calendar pour mes dates. Mais lorsque la date choisie est inférieur ou égale à 1970, mon application crash, du moins j'ai une erreur hibernate.
    En principe à chaque année choisie par l'utilisateur, j'ajoute 1900 pour avoir la date actuel

    Voici l'erreur hibernate:

    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
    javax.persistence.RollbackException: Error while commiting the transaction
    	at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:71)
    	at com.mbassi.curve.core.crud.gestion_inscription.InstitutionJpaController.create(InstitutionJpaController.java:51)
    	at com.mbassi.curve.core.engine.Gestion_Inscription.editer_institution(Gestion_Inscription.java:1406)
    	at com.mbassi.curve.core.engine.Gestion_Inscription.create_institution(Gestion_Inscription.java:1380)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:623)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
    	at sun.rmi.transport.Transport$1.run(Transport.java:177)
    	at sun.rmi.transport.Transport$1.run(Transport.java:174)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    	at java.lang.Thread.run(Thread.java:717)
    Caused by: org.hibernate.exception.DataException: Could not execute JDBC batch update
    	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
    	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
    	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
    	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
    	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
    	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
    	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
    	at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
    	... 18 more
    Caused by: java.sql.BatchUpdateException: Data truncation: Incorrect datetime value: '1969-04-01 09:59:57' for column 'date_creation' at row 1
    	at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2018)
    	at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1449)
    	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
    	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
    	... 26 more

  2. #2
    Membre actif Avatar de Roy Miro
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    273
    Détails du profil
    Informations personnelles :
    Âge : 38
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 273
    Points : 290
    Points
    290
    Par défaut
    Vérifie la représentation de la donnée date de ton SGBD.
    Peut-être que "1969-04-01 09:59:57" ne respecte pas le format attendu par le sgbd.

  3. #3
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Bonjour,
    Peut on voir comment cette colonne date a été mappée?

  4. #4
    Membre actif Avatar de aljessy
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2010
    Messages
    319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2010
    Messages : 319
    Points : 200
    Points
    200
    Par défaut
    J'ai fini par résoudre mon problème. En fait en base de donnée le type de la colonne était TIMESTAMP or ce dernier n'accepte pas les date antérieur à 1970. Je n'ai eu qu'a remplacé le type de la colonne par DATETIME

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

Discussions similaires

  1. problème avec les dates!!
    Par JauB dans le forum MS SQL Server
    Réponses: 1
    Dernier message: 28/10/2005, 09h16
  2. problème avec les dates nulles
    Par shingo dans le forum SQL Procédural
    Réponses: 1
    Dernier message: 30/09/2005, 12h32
  3. probléme avec une date/string dans un CommandText
    Par critok dans le forum Bases de données
    Réponses: 5
    Dernier message: 09/02/2005, 15h30
  4. [SQL] problème avec les date et les group By
    Par Stef784ever dans le forum Langage SQL
    Réponses: 3
    Dernier message: 23/11/2004, 09h18
  5. Interbase - dbExpress -> problème avec les dates
    Par marghett dans le forum Bases de données
    Réponses: 4
    Dernier message: 02/07/2004, 03h55

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