-->
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.  [ 2 posts ] 
Author Message
 Post subject: many-to-one and delete
PostPosted: Fri May 21, 2004 5:48 pm 
Newbie

Joined: Fri May 21, 2004 5:30 pm
Posts: 3
Hi guys,
I have two classes and there is many-to-one relationship from class A to B. There isn't any relationship from B to A. The A class has getB method which return the B class. I would like to make that delete the B class should delete all A classes which refer to that B (session.delete(instanceOfClassB) ==> delete the instanceOfClassB AND delete all A classes which refer to that instanceOfClassB).

/** @hibernate.class table="A" */
public class A {
private int id = -1;
private String nazwa;
private B b;

/** @hibernate.id generator-class="native" column="a_id" unsaved-value="-1"
* @hibernate.generator-param name="sequence" value="A_sequence" */
public int getId() {
return id;
}

/** @hibernate.property */
public String getNazwa() {
return nazwa;
}

/**@hibernate.many-to-one column="fk_b_id" cascade="all" */
public B getB() {
return b;
}

public void setB(B b) {
this.b = b;
}

public void setNazwa(String nazwa) {
this.nazwa = nazwa;
}

public void setId(int id) {
this.id = id;
}
}

/**@hibernate.class table="B" */
public class B{
private int id = -1;
private String nazwa;

/**
* @hibernate.id generator-class="native" column="b_id" unsaved-value="-1"
* @hibernate.generator-param name="sequence" value="B_sequence"*/
public int getId() {
return id;
}

/** @hibernate.property */
public String getNazwa() {
return nazwa;
}

public void setNazwa(String nazwa) {
this.nazwa = nazwa;
}

public void setId(int id) {
this.id = id;
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 26, 2004 5:51 am 
Newbie

Joined: Wed May 26, 2004 5:47 am
Posts: 1
Hello,

i have the same problem here. Any Tip to get this handled ?.

Thanks

Robert


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.