These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problème lors d'insertion sur table jointe
PostPosted: Wed Aug 15, 2007 2:00 pm 
Newbie

Joined: Wed Aug 15, 2007 1:50 pm
Posts: 1
Hibernate : 3.2.5.ga
DataBase : HSQLDB 1.8.0.7

Bonjour,

Je possède une classe Compte qui contient un code, un identifiant, un motDePasse et une description (qui peut être dans une langue différente)

Lors de l'insertion, hibernate lance une exception bizarre :
Code:
ERROR - Wrong data type: java.lang.NumberFormatException: For input string: "Compte utilisateur de Monsieur Test Test"


Je n'arrive pas à déterminer la cause de cette exception.
La surcharge du sql-insert m'est necessaire pour choisir la bonne description vis à vis de la langue active de la base (LANGUES.Active=true)
Pour info, le update fonctionne bien sur une instance deja crée en bd.

Quelqu'un verrait-il une explication svp ?
Merci.

Mon fichier de mapping :

Code:
<class name="Compte" table="COMPTES">
      <id name="codeCompte" column="CodeCompte" unsaved-value="-1">
         <generator class="native" />
      </id>
      <property name="identifiant" type="string" not-null="true" column="Identifiant" />
      <property name="motDePasse" type="string" not-null="true" column="MotDePasse" />
      ...
      <join table="COMPTES_DESCRIPTIONS" optional="true">
         <subselect>SELECT CodeCompte, Description FROM COMPTES_DESCRIPTIONS INNER JOIN LANGUES ON COMPTES_DESCRIPTIONS.CodeLangue = LANGUES.CodeLangue WHERE LANGUES.Active = true</subselect>
         <key column="CodeCompte" />
         <property name="description" type="string" not-null="false" column="Description" />
         <sql-insert>INSERT INTO COMPTES_DESCRIPTIONS (CodeCompte, CodeLangue, Description) VALUES (?, (SELECT CodeLangue FROM LANGUES WHERE LANGUES.Active = true), ?)</sql-insert>
          <sql-update>UPDATE COMPTES_DESCRIPTIONS SET Description=? WHERE CodeCompte=? AND CodeLangue=(SELECT CodeLangue FROM LANGUES WHERE LANGUES.Active = true)</sql-update>
      </join>
   </class>


Code :

Code:
Compte compte = new Compte();
   compte.setIdentifiant("test.test");
   compte.setMotDePasse("test");
   compte.setDescription("Compte utilisateur de Monsieur Test Test");
   // Dao compte appelle normallement saveOrUpdate sur une session valide
daoCompte.enregistrerCompte(compte);


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.