-->
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: One to Many unidirectionnal, pb with list.remove()
PostPosted: Wed Dec 06, 2006 1:20 pm 
Newbie

Joined: Wed Dec 06, 2006 12:48 pm
Posts: 1
Hi,

Basically i have an entity 'FamilleGarantieService' which has a list of 'RisqueCouvert'
RisqueCouvert cannot exist without a FamilleGarantieService.

I have set my database to have 2 RisqueCouvert in my list.

I m trying to remove the first element of the list doing so :

beginTx();

//load from the repository
FamilleGarantieService f1 = repos
.chercherFamilleGarantieParIdentifiant(FAMILLE_ID1);

//get the element we are going to delete
RisqueCouvert rco = f1.getRisquesCouverts().get(0);

//delete from the list
f1.getRisquesCouverts().remove(rco);

commitTx();

beginTx();
f1 = repos
.chercherFamilleGarantieParIdentifiant(FAMILLE_ID1);

assertEquals(1, f1.getRisquesCouverts().size());
commitTx();

And then i have a assert fails on the equals, the size is still 2.

My mapping :

@Entity
@Table(name = "FamilleGarantieService")
public class FamilleGarantieService {
[...]
/** Les risques couverts */
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name="FamilleGarantieService_id",nullable=false)
private List<RisqueCouvert> risquesCouverts;


The sql is only select ...
If i modify one of my entities, there is sql update.
If i change nullable=true, there the FK(FamilleGarantieService_id) is set to NULL (and i have a contraint error so)

I can add, i can delete f1 and the RisqueCouvert's elements will be deleted too. If i do entityManager.remove(rco) it s working too.
But what i want to do is list.remove(child) and have a sql delete !

Any idea ?
thanks a lot.

Hibernate version: 3.2


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.