-->
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: Cascading on new object
PostPosted: Tue Oct 04, 2005 1:51 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
I've a table structure similiar to the one below:

Code:
CREATE TABLE [dbo].[Blogs] (
    [blog_id] [int] IDENTITY (1, 1) NOT NULL ,
    [blog_name] [varchar] (50) NULL ,
) ON [PRIMARY]

CREATE TABLE [dbo].[Posts] (
    [post_id] [int] IDENTITY (1, 1) NOT NULL ,
    [post_title] [varchar] (50) NULL ,
    [post_blogid] [int] NULL ,
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]


Class Blog has a Set of posts which is defined as inverse=true.
Right now when I add a new post to the Posts collection on a Blog it's not being saved unless I explicity tell the session to save it.

What I want to happen is that if I add to the set of posts, it would save automatically.
The idea is for cases similar to this one:

Code:
using (ISession seesion = factory.CreateSession())
{
    Blog blog = session.Load(typeof(Blog),1);
    blog.Posts.Add(new Post());
}


Is it possible to do this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 04, 2005 2:28 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, add cascade="save-update" to the mapping of the set of posts.


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.