-->
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.  [ 6 posts ] 
Author Message
 Post subject: Auto fill stamp fields in all tables...
PostPosted: Wed Sep 07, 2005 8:14 pm 
Newbie

Joined: Wed Aug 31, 2005 9:29 pm
Posts: 14
I am working with a database in which every table has four stamp fields:

CREATEDATE
CREATEUSER
MODIFYDATE
MODIFYUSER

Back in my typed dataset days, I used a custom CommandBuilder that automatically adds these fields to the generated INSERT and UPDATE statements. Is there anywhere in nhibernate that I can hook into to transparently fill these fields?

Just thought I'd ask before adding the four properties to all my objects (or creating a base object with them and inheriting everything from that) and making sure they


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 9:52 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Take a look at: 3.1.8. timestamp

If it doesn't solve your problem, give more details (when do you want this fields to be set and with which values ?)

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 6:31 pm 
Senior
Senior

Joined: Sat Sep 10, 2005 3:46 pm
Posts: 178
I have the same situation with the simple audit fields. What I did is create an Audit component in each of my mappings that reflects the audit properties.

So I access the audit fields like this. user.Audit.DateCreated. Of course you don't have to take the component route if you want your audit data accessible right oiff of your root object.

Regardless each class that has the audit data implements the IAuditable interface.

I then use an interceptor to update the appropriate fields automatically when a persistence operation is performed.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 11:14 pm 
Newbie

Joined: Wed Aug 31, 2005 9:29 pm
Posts: 14
Thanks, that looks like a very useful hook...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 2:02 am 
Newbie

Joined: Wed Apr 12, 2006 12:40 am
Posts: 1
jnapier wrote:
I have the same situation with the simple audit fields. What I did is create an Audit component in each of my mappings that reflects the audit properties.

So I access the audit fields like this. user.Audit.DateCreated. Of course you don't have to take the component route if you want your audit data accessible right oiff of your root object.

Regardless each class that has the audit data implements the IAuditable interface.

I then use an interceptor to update the appropriate fields automatically when a persistence operation is performed.


I am new to NHibernate. I am trying to do the same, can you please post some code snippets or link to a sample implementation
Cheers


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 15, 2006 6:10 am 
Newbie

Joined: Sat Apr 15, 2006 6:07 am
Posts: 4
Please see NHibernate Ref Doc version 1.0.2
if PDF see page 73

search for Interceptors or goto section 9.10


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