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.  [ 3 posts ] 
Author Message
 Post subject: cannot delete child in one-to-one.
PostPosted: Mon Dec 13, 2004 10:49 am 
Newbie

Joined: Wed Nov 10, 2004 11:25 am
Posts: 11
Hibernate version: 2.1.7

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.test.oneToOne.OneToOneParent" table="one_to_one_parent">
<id name="pk" column="pk" type="java.lang.Long">
<generator class="sequence">
<param name="sequence">hibernate_sequence</param>
</generator>
</id>
<property name="comment" column="comment" type="java.lang.String"/>
<one-to-one
name="child"
property-ref="parent"
cascade="all"
class="com.test.oneToOne.OneToOneChild"
constrained="false"/>
</class>

<class name="com.test.oneToOne.OneToOneChild" table="one_to_one_child">
<id name="pk" column="pk" type="java.lang.Long">
<generator class="sequence">
<param name="sequence">hibernate_sequence</param>
</generator>
</id>
<many-to-one
name="parent"
class="com.test.oneToOne.OneToOneParent"
column="fk_parent"
cascade="save-update"/>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
tx = hibernateSession.beginTransaction();
hibernateSession.saveOrUpdate(bean);
tx.commit();


The generated SQL (show_sql=true):update one_to_one_parent set comment=? where pk=?

Code Parent:
public class OneToOneParent extends HBBean{
private String comment;
private OneToOneChild child;

public String getComment() {
return comment;
}

public void setComment(String comment) {
this.comment = comment;
}

public OneToOneChild getChild() {
return child;
}

public void setChild(OneToOneChild child) {
if(child != null){
child.setParent(this);
}
this.child = child;
}
}

Code Child:
public class OneToOneChild extends HBBean{
private OneToOneParent parent;

public OneToOneParent getParent() {
return parent;
}

public void setParent(OneToOneParent parent) {
this.parent = parent;
}
}


I want to delete child (OneToOneChild) in parent (OneToOneParent). I set null to a parent's property: child
but it is not deleted :-( Is there a way to?

_________________
Vladimir
www.devitnow.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 13, 2004 10:57 am 
Newbie

Joined: Wed Nov 10, 2004 11:25 am
Posts: 11
I've searched all documents and forum but couldn't find :-(

_________________
Vladimir
www.devitnow.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 13, 2004 12:51 pm 
Newbie

Joined: Wed Nov 10, 2004 11:25 am
Posts: 11
pls, help me. Any help is welcome.

_________________
Vladimir
www.devitnow.com


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