db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henning Schmiedehausen <...@intermeta.de>
Subject Re: PostgreSQL ID generation
Date Wed, 25 May 2005 12:18:23 GMT
Hi,

afaik you don't need to run the "get value from sequence" under a
Transaction because it is already atomic. Else your sequence could
funnily go forward and backward (if you roll back a transaction).

the "select nextval('sequence_name') is AFAIK not only hibernate
compatible (which does an even more efficient thing by combining HiLo
with a Sequence) but the "only right way to do this". The old sequence
generator (which used select currval('sequence_name') ) could IMHO be
tricked into returning the same value multiple times.

IIRC, select currval() is intended when you want to save the state of a
sequence.

	Regards
		Henning



On Tue, 2005-05-24 at 08:49 +0200, Thomas Fischer wrote:
> 
> 
> 
> Henning,
> 
> I have just read your archived message
> 
> http://nagoya.apache.org/eyebrowse/ReadMsg?listName=torque-dev@db.apache.org&msgNo=4107
> 
> regarding the generations of ids in postgresql.
> I believe the current solution to generate an id is the standard way of
> using a sequence (if I remember correctly, you implemented it :-) ):
> 
> (- start a transaction)
> - get a value from the sequence
> - set the primary key in the object from the sequence
> - save the object
> (- commit the transaction)
> 
> Is this compatible with Hibernate ?
> 
> I still have to think about the id-method parameter (and check whether it
> works in head), but today is the first time I came across it.
> 
>     Thomas
> 
> --------------------------------------------------------------------
> 
> Dr. Thomas Fischer
> Software-Entwicklung
> Tel. +49 (0) 7531 36598-22
> Fax +49 (0) 7531 36598-11
> E-Mail  fischer@seitenbau.com
> 
> SEITENBAU GmbH
> Robert-Gerwig-Str. 10-12
> D-78467 Konstanz
> http://www.seitenbau.com
> 
> Amtsgericht Konstanz HRB 1528
> USt-IdNr.: DE 1905 525 50
> 
> Geschäftsführer:
> Florian Leinberger | Sebastian Roller | Rainer Henze
> Prokuristen:
> Jan Bauer | Stefan Eichenhofer
> 
-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

      RedHat Certified Engineer -- Jakarta Turbine Development
   Linux, Java, perl, Solaris -- Consulting, Training, Engineering

                     4 - 8 - 15 - 16 - 23 - 42


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message