-->
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.  [ 5 posts ] 
Author Message
 Post subject: Can you change cascading relationships at runtime?
PostPosted: Fri Jul 07, 2006 11:33 am 
Beginner
Beginner

Joined: Tue Nov 29, 2005 4:42 pm
Posts: 49
Location: Atlanta, GA
I know there is a way to load relationships early at runtime, and hibernate suggests we mark all relationships as lazy then eagerly load then at runtime. It seems the same might apply to cascade relationships. However, I have not found any mention of this in the docs. Is there a way to change cascading relationships at runtime?

Thanks
Charlie


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 12:55 pm 
Newbie

Joined: Tue Apr 19, 2005 3:16 pm
Posts: 18
I'm not exactly sure what you're asking, Charlie. Could you provide an abstract example of what you're wanting to accomplish?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 3:12 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
I've recently run across the same question. Shortly, the answer is no.

But, but ! There is a "nifty workaround" http://forum.hibernate.org/viewtopic.ph ... 28#2312128 :-)

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 5:42 pm 
Beginner
Beginner

Joined: Tue Nov 29, 2005 4:42 pm
Posts: 49
Location: Atlanta, GA
Sure. Let's say I have two classes Document and Content. Document has some meta data, and content stores some information about the content, but really it's just the byte array of the content.

class Document {
@OneToOne( fetch = FetchType.EAGER, cascade = CascadeType.ALL )
@JoinColumn(name="content_id")
Content content;
}

class Content {

Integer id;

Date lastModifiedAt;

User lastModifiedBy;

byte[] contents;

}

Now sometimes I want to commit the changes I make to Content when I saveOrUpdate Document and sometimes I don't. However since I've marked this as CascadeType.ALL it gets commited whenever I commit Document. Is there a way I can at runtime change the cascade settings betwen Document and Content?

My particular problem is that I have a case when I don't want to commit changes the user has made in Content because they've modified something in Document.

Thanks
Charlie


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 3:36 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
It's impossible, as I said. I already wanted to do this a couple of days ago. Look at the answer tenwit provided me in the thread I opened for this : subject.http://forum.hibernate.org/viewtopic.ph ... 28#2312128

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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