-->
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: Problem with auto_increment
PostPosted: Tue May 22, 2007 5:17 am 
Newbie

Joined: Wed May 09, 2007 8:49 am
Posts: 9
Hi All,

I am facing a problem with auto_increment..

I have two application and both are using the same database..

when i save some value this auto_increment is getting the old value which is updated already.So in that time i am gettiong exception..

CREATE TABLE CLIENT (
CLIENTID int NOT NULL AUTO_INCREMENT,
SERIALNUMBER varchar(64) NOT NULL,
TIMESTAMP TIMESTAMP NOT NULL,
SERVER varchar(3) NOT NULL,
CONSTRAINT PK_ClientConnLog PRIMARY KEY
(
CLIENTID
)

);


<id name="clientId" type="int" column="CLIENTID" >
<generator class="increment"/>
</id>

i am doing commit properly after my save..


Pls let me know if something wrong in my table creation or problem in the xml file in the above..

thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 5:57 am 
Newbie

Joined: Thu Jan 26, 2006 6:19 am
Posts: 19
I guess, two applications causes this problems,
They probably cache the latest ids assigned.
you can use an extra table, to fix this problem.

the Hilo Generator automaticly does this, as given below:

Code:
<id name="id" type="long" column="uid" unsaved-value="0">
<generator class="net.sf.hibernate.id.TableHiLoGenerator">
<param name="table">uid_table</param>
<param name="column">next_hi_value_column</param>
</generator>
</id>


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 7:51 am 
Newbie

Joined: Wed May 09, 2007 8:49 am
Posts: 9
Hi,

thanks for ur reply...
i can't add any table now..

is there anyother possibility to make it work with my current implementation?

i am doing session.flush()...i am not sure still how its taking the values from cache?

thanks.


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.