-->
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: Doing custom actions on Save of Object
PostPosted: Sat Mar 25, 2006 11:32 am 
Newbie

Joined: Sat Mar 25, 2006 11:17 am
Posts: 2
Hey,

I like to do custom actions when I save an object. For instance:

I got following object:

class Document
{
public GUID UID
{
get;
set;
}

public IOResource
{
get;
set;
}
}

When I save the Document the IOResource is saved also, normal NHibernate usage. Now if you save IOResource something has to be writen to the filesystem on base of the IOResource UID. So IOResource needs to be saved first so that NHibernate fills in its UID and then I want to save something to the disk. Is this possible (with an Nhibernate Event or a special interface) otherwise I have to make separate objects for my DataLayer and DomainModelLayer (wraps DataObjects)

If possible, can this be done in a transaction so that if the write to disk fails the creating of the object in the database is undone.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 26, 2006 10:05 am 
Regular
Regular

Joined: Tue Mar 07, 2006 11:18 am
Posts: 54
Location: Berlin
I guess you could basicly do that by using a Observer Pattern watching for the ID to be changed.
But did you check out the PostInstertEventListener class?

simon


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 7:29 am 
Newbie

Joined: Sat Mar 25, 2006 11:17 am
Posts: 2
Thanks I will take a look at it.


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.