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: Adding Audit Columns - Timestamp fields and getdate()
PostPosted: Fri Jul 14, 2006 9:43 am 
Newbie

Joined: Fri Jul 14, 2006 9:13 am
Posts: 2
Location: Manchester, England
I need to add audit information to certain entities - in the usual format

createdDate, createdBy, modiedDate, modifiedBy.

The problem I have is I want the createdDate and modifiedDate values to be the database time values not the application values.

How can I do this in NHibernate; ideally I could set the values using a property type of formula (i.e. formula=getdate()) but formula values do not map to a column.

I can't use the <timestamp> attribute as I don't want this timestamp to be used in an 'optimistic locking' context as we already use a integer versionid to do this.

Problem in a nushell is how to I get NHibernate to insert (and update) database columns with the current database time getdate() (SQL Server)

Thanks

John


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 17, 2006 10:41 am 
Beginner
Beginner

Joined: Tue Jan 17, 2006 12:55 pm
Posts: 49
It sounds like what you really want are database triggers.. this a good old-fashioned technique for this kind of stuff.


Top
 Profile  
 
 Post subject: No triggers are not what I want
PostPosted: Mon Jul 17, 2006 11:24 am 
Newbie

Joined: Fri Jul 14, 2006 9:13 am
Posts: 2
Location: Manchester, England
a) I don't want to use triggers all I want to do is to update a column with a date time i.e. get hibernate to use the value getdate() instead of reading this value from a property

b) I can't use triggers with SQL server; I want to modify data on the same table as my business object; you can't change the value of the trigger 'Inserted' table in SQL Server; least ways you can but it won't go on to write it to the database

I could get things to work by updating my property with the application time (from the web server) or by reading the database directly to find the current DB time using an Interceptor but I was hoping NHibernate would provide an easy option.

John


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.