-->
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-one mapping - How to delete?
PostPosted: Sat May 21, 2005 12:01 pm 
Newbie

Joined: Mon Feb 16, 2004 11:28 pm
Posts: 16
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

2.1:

Mapping documents:
<hibernate-mapping>
<class name="com.acme.Employee" table="EMPLOYEE">
<id name="employeeId" column="EMPLOYEE_ID" type="long" unsaved-value="null">
<generator class="identity"/>
</id>
<property name="firstName"
column="FIRST_NAME"
type="string"
not-null="true"/>

<property name="lastName"
column="LAST_NAME"
type="string"
not-null="true"/>


<one-to-one name="phone"
class="com.acme.Phone"
cascade="all" />
</class>
</hibernate-mapping>

<hibernate-mapping>
<class name="com.acme.Phone" table="PHONE">
<id name="phoneId" column="PHONE_ID">
<generator class="foreign">
<param name="property">employee</param>
</generator>
</id>

<one-to-one name="employee"
constrained="true"
class="com.acme.Employee" />

<property name="phoneNumber" column="PHONENUMBER" type="string" not-null="true" />
<property name="phoneExtension" column="PHONEEXTENSION" type="string" not-null="false" />
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Using Spring

Full stack trace of any exception that occurs:

Name and version of the database you are using: MySQL 4


My question is if I save an Employee with a phone everything works just fine. I'm trying to delete that phone number off the employee by calling employee.setPhone(null) and then calling saveOrUpdate on the dao method. cascade is set to all for the phone reference. Shouldn't I be able to do this? I don't want to have to delete phone directly if I don't have to.


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.