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: Many-to-one with cascade="none" AND null values
PostPosted: Wed Jun 25, 2008 7:11 am 
Newbie

Joined: Wed Jun 25, 2008 6:50 am
Posts: 1
Hi Guys,
I have a small problem with many-to-one relationship.
I have a table called inputs which has many-to-one relationship with a table called webpages, now an input can either have a webpage or a null value,
i can save it in the database in either case but when i try to delete an input with null webpage value it throws a TransientObjectException saying that webpage which is null has not been saved,
Here is the mapping,


input.hbm.xml has this

<many-to-one name="webPage"
class="WebPage"
column="webpage_id"
not-found="ignore"
not-null="false"
cascade="none"
/>


and i am doing s.saveOrUpdate(input);

i suspect it to be coz of cascade="none", but not sure whats the work around,
I will really appreciate any help.

cheers,
Adnan


Top
 Profile  
 
 Post subject: Re: Many-to-one with cascade="none" AND null values
PostPosted: Wed Jun 24, 2009 2:11 am 
Newbie

Joined: Sun Mar 01, 2009 11:11 pm
Posts: 9
Hi,

Did you find the solution, I have similar problem, In my case i have a User Class and Employee Class, User is related to Employee,

When I try to save user I get TransientObjectException and says that Employee has to be saved. But In My case, Employee is already created and it is in DB, I am just adding a child which is user.


Top
 Profile  
 
 Post subject: Re: Many-to-one with cascade="none" AND null values
PostPosted: Fri Jun 26, 2009 3:04 am 
Newbie

Joined: Fri May 29, 2009 2:21 am
Posts: 12
Hi kannan,

Since u r saying ur User is related to Employee, how do u expect saving it if its not instantiated on Java side.
If ur User table has FK of Employee then probably you might retrieve the saved Employee against which u would save ur user.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.