Bonjour à tous, voila j'ai un problème qui dure depuis un petit moment et je ne trouve pas la solution.

Je débute en Hibernate et pour l'instant je modélise deux classes : un Client et un Compte.

Et pour finir mes deux fichiers de mapping :

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
 
<hibernate-mapping>
 
    <class name="Client" table="client">
 
        <id name="Num_Client" type="int" column="num_client">
                <generator class="increment"/>                
        </id>
 
	<property name="Nom" type="string" length="50" column="nom" not-null="true"/>
 
	<property name="Prenom" type="string" length="50" column="prenom" not-null="true"/>
 
	<property name="Rue" type="string" length="100" column="rue" not-null="true"/>
 
	<property name="Ville" type="string" length="50" column="ville" not-null="true"/>
 
	<property name="CP" type="string" length="5" column="CP" not-null="true"/>
 
        <set name="ListeCompte" inverse="true" cascade="all, delete-orphan" lazy="false">
            <key column="num_client"/>
            <one-to-many class="Compte"/>
        </set>
 
    </class>
 
</hibernate-mapping>
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
 
<hibernate-mapping>
 
    <class name="Compte" table="compte">
 
        <id name="Num_Compte" type="string" column="num_compte">
                <generator class="native"/>                
        </id>
 
	<property name="Type" type="string" column="type" not-null="true"/>
 
	<property name="Solde" type="float" column="solde" not-null="true"/>
 
        <many-to-one name="Num_Client" column="num_client" not-null="true" class="Client"/>
 
    </class>
 
</hibernate-mapping>
Donc mon problème intervient lorsque je veux ajouter un Compte à un de mes Client, je me retrouve avec l'erreur 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
 
Hibernate: select max(num_client) from client
Hibernate: insert into client (nom, prenom, rue, ville, CP, num_client) values (?, ?, ?, ?, ?, ?)
Le client test2 a été ajouté avec l'id : 1
 
Chargement du client.
 
Client d'id1
 
Création du compte.
 
Hibernate: select client0_.num_client as num1_0_0_, client0_.nom as nom0_0_, client0_.prenom as prenom0_0_, client0_.rue as rue0_0_, client0_.ville as ville0_0_, client0_.CP as CP0_0_ from client client0_ where client0_.num_client=?
Hibernate: select listecompt0_.num_client as num4_1_, listecompt0_.num_compte as num1_1_, listecompt0_.num_compte as num1_1_0_, listecompt0_.type as type1_0_, listecompt0_.solde as solde1_0_, listecompt0_.num_client as num4_1_0_ from compte listecompt0_ where listecompt0_.num_client=?
Ajout du compte au client.
 
Hibernate: update compte set type=?, solde=?, num_client=? where num_compte=?
19 mars 2008 10:37:55 org.hibernate.property.BasicPropertyAccessor$BasicGetter get
GRAVE: IllegalArgumentException in class: Client, getter method of property: Num_Client
19 mars 2008 10:37:55 org.hibernate.event.def.AbstractFlushingEventListener performExecutions
Erreur d'ajout de compte : org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of Client.Num_Client
GRAVE: Could not synchronize database state with session
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of Client.Num_Client
        at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
        at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:183)
        at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3591)
        at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3307)
        at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
        at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:218)
        at org.hibernate.type.EntityType.getIdentifier(EntityType.java:397)
        at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:78)
        at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1997)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2371)
        at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
        at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
        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 Compte.CreateStoreCompte(Compte.java:104)
        at Main.main(Main.java:32)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
 
...
Donc voila, d'après mes recherches sur Google, c'est une erreur qui est assez fréquente mais je n'ai pas trouvé de solution ... donc j'en appel à votre expérience dans le domaine d'Hibernate.

Merci d'avance.