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: Database generated timestamping
PostPosted: Mon Jan 08, 2007 7:08 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
I've got a wierd one here...we've developed our domain model to use a version column (int) with the NHibernate <version> mapping and all works beautifully.

Now, however, we have the requirement to add a timestamp to our objects so we know when they were last updated. The problem is that we need the database to add the timestamp rather than the client where NHibernate is running as we need to make sure that the date/times stored are consistent.

I was thinking of using the <timestamp> mapping but we don't want to change our domain objects from having a version property that is managed by NHibernate as we have an external dependency on those version properties. It looks like it's not possible to use both <timestamp> and <version> in the same class, so I think that's out.

Is there any other solution to this?

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 9:27 am 
Regular
Regular

Joined: Tue Jan 03, 2006 11:43 am
Posts: 51
Location: Sweden
Can't you map it like this:

<property name="LastUpdated" column="lastUpdated" insert="false" update="false" />

so that the client never insert/updates the column? Maybe I misunderstood you.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 10:00 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
Actually, what I'm after is that every time the object state is updated into the database that the LastUpdated column will be updated with the current date/time of the database server.

Symon.


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.