-->
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.  [ 5 posts ] 
Author Message
 Post subject: How to update the relation table describe in a set collectio
PostPosted: Fri Dec 03, 2004 4:31 am 
Newbie

Joined: Fri Dec 03, 2004 3:45 am
Posts: 3
I Nico
I'm french so may be my english is not perfect; However, i'm trying to expose you my Problem.
First let me present you one of the part of my Database.
There are two main tables which are a primary key:
TTACHE_EXT
ID_TACHE Varchar(20) PK
NOMFIC VARCHAR(50)

The first one
TANNUAIRISTE
ID_ANNUAIRISTE Varchar(20) PK
NOM VARCHAR(50)
The second one

TTACHE_ANNU
ID_TACHE FK
ID_ANNUAIRISTE FK
DATE_BEGIN_TACHE DATE
DATE_END_TACHE DATE

is the relation table

To describe this model, i declare two files
one to represent TANNUAIRISTE and an another
to TTACHE, which contains the definition of the
set collection

See the date of this two file

in client.hbm.xml

<class name="Client" table="TANNUAIRISTE">
<id name="id" column="ID_ANNUAIRISTE">
<property name="nom" column="NOM">
...

</Class>

in tache.hbm.xml
<class name="Tache" table="TTache">
<id name="id" column="ID_TACHE">
<property name="nom" column="NOM">
...
<SET name="tacheClients" >
<INDEX column="ID_TACHE">
<composite-element class="TacheClient">
<many-to-one name="client" class="CLIENT" column="ID_ANNUAIRISTE">
<property name="dateDebut" column="DATE_BEGIN_TACHE">
<property name="dateFin" column="DATE_END_TACHE">
</composite-element>
</SET>
</class>


the depend class looks like it:

public class Tache {
private Set tacheClients;

+the getters/setters

public addTacheClient( Client _client, Date _dateDebut, Date _dateFin) {

TacheClient myTacheClient = new TacheClient();
myTacheClient.setDateDebut(_dateDebut);
myTacheClient.setDateFin(_dateFin);
myTacheClient.setClient(_client);
this.tacheClient.add(myTacheClient);
} //end of the method

}//end of the class


public class TacheClient implements Serializable {

private Client client;
private date datedebut;
private date datefin;




+the getters/setters and method equals/hashcode

}


I'm trying to create a new record in the table tache and many in the relation table TTACHE_ANNU

Tache myTache = new TACHE();
myTache.setNom("Toto");
...
myTache.addTacheClient( myClientXX, dateXX, dateYY);

I load a session so that i can register my New Tache and i hoped
a record in the relation table

I do ths code:
Transaction tx = session.beginTransaction();
session.save(myTache);
tx commit;

In fact, my New tache is registered but not my Elemnt in the collection..
I dont understand why not..therefore, i have no error neither warning

I will happy if someone can help me

Thanks

























[/i]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 03, 2004 4:37 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
hi,

could it be that you've forgotten the "cascade"-attribute at your set? Without that, the changes to your collection won't be synchronized with your database ...

(i think :) )

gtx
curio


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 03, 2004 4:56 am 
Newbie

Joined: Fri Dec 03, 2004 3:45 am
Posts: 3
Thanks for your response
In fact i actually put this attribute and its value is "cascade"
and nothing is happened...
nicolas


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 03, 2004 4:57 am 
Newbie

Joined: Fri Dec 03, 2004 3:45 am
Posts: 3
error
the value of cascade's attribute is "all"
nico


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 13, 2004 6:33 am 
Newbie

Joined: Mon Dec 13, 2004 6:26 am
Posts: 2
Hi

Have You resolved this, Nico?
I've got simmiliar problem.


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

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.