-->
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: Using both version and timestamp
PostPosted: Thu Jan 04, 2007 8:38 am 
Newbie

Joined: Thu Jan 04, 2007 8:22 am
Posts: 12
Hibernate version: 3.2.1

Name and version of the database you are using: Oracle 10g R2

Hi,

We're starting a new application from scratch and we'll be using hibernate 3.2.1 for persistence. The database design was done before this choice was made, so now, I'm trying to request changes to the design.

The current design uses audit fields on every table. Those fields include last_updated, which has an Oracle type of DATE. Following the guidelines in the book, I'm planning to request the database designers to add a version field to every table, so that it can be used for optimistic concurrency control to avoid the problems associated with timestamps.

It seems, though, that the last_updated field has another use, which is auditing. So, probably, both fields need to live together.

I wonder if it's possible (or even correct) to specify both a version and timestamp tags inside a class.

Another approach would be to create a trigger for every table that would update the value of this field whenever the record is updated. But would hibernate be able to pickup this value?

Please advice.

Every help is appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 04, 2007 9:00 am 
Newbie

Joined: Thu Jan 04, 2007 8:22 am
Posts: 12
I just came across an explanation of how Hibernate performs a select of the entity that contains database generated fields right after it's inserted/updated in the database. So, now I understand that I don't need to use both version and timestamp, but rather use version and specify the last_upated field as a generated field.

The problem is, I feel like this extra query that is done after insertion is an overhead, since in 99% of the cases, I won't be using those fields, i.e. created and last_updated. I anticipate that those fields might be used in at most, one or two reports in the whole application (if any).

Would you recommend not mapping those fields at all, and using a different approach for those reports (if any)? What would be the best approach?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 07, 2007 2:27 am 
Newbie

Joined: Thu Jan 04, 2007 8:22 am
Posts: 12
repost


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.