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: Version Column - auto incremented - non primary key issue
PostPosted: Fri Oct 12, 2007 12:04 pm 
Newbie

Joined: Fri Oct 12, 2007 11:52 am
Posts: 5
What I have is a design issue.
Consider this Schema:
TBL_RESRC
Columns: ID (PK), PARENT (FK), CATERGORY_ENUM, NAME_DESC, VERSION_NUM

My requirement is to auto increment VERSION_NUM columm
Logic: version starts with 0 and increments there on, and is unique
Additional constraint: has to work in clustered environment
DB: Oracle 10g
ORM: Hibernate

My methods:
Use sequence in oracle, then add "trigger" to insert next val into the VERSION_NUM column

2 Questions:

* Is there a better way than this?
* Can I please have the hibernate mapping for using a sequence. Will the version in the doman object have to be int, long or something else


Thanks,
H-nate Learner


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 14, 2007 2:11 am 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
You can let hibernate do all this for you.

By default, hibernate uses optimistic locking using a version field.

So as long as you have a column that can be mapped using <version> in the mapping file you are good to go.

Here's the details.
http://www.hibernate.org/hib_docs/v3/re ... on-version

_________________
Don't forget to rate the reply if it helps..:)

Budyanto


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 15, 2007 11:09 am 
Newbie

Joined: Fri Oct 12, 2007 11:52 am
Posts: 5
Thanks himawan


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.