-->
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.  [ 1 post ] 
Author Message
 Post subject: Unique column generation process
PostPosted: Thu Sep 13, 2007 12:11 pm 
Newbie

Joined: Thu Sep 13, 2007 4:12 am
Posts: 1
Hi, i have the next many to one relation:

_____________WORKS_______________
WORK_ID (PK) BIGINT AUTOINCREMENT
WORK_CODE VARCHAR(10)
USER_ID BIGINT (FK)

___________USERS_________________
USER_ID (PK) BIGINT AUTOINCREMENT

I have to generate the UNIQUE column WORK_CODE with the following format:

4 digits alphanumeric code identifying the owner (user)-6 digits autonumeric. For example, i'll have this 2 work_codes for one user.

A001-000100
A001-000101

The next work for another user wil be:

A002-000100
A002-000101
.
.

So, i have to query for the last work of the user and then calculate the code. I must to isolate this process of concurrent access. What is the better aproach to do this? (Triggers, synchronized method...)

Thank you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.