users@glassfish.java.net

[Fwd: Use of SERIAL and BIGSERIAL w/ EJB3 and POSTGRES]

From: Shreedhar Ganapathy <Shreedhar.Ganapathy_at_Sun.COM>
Date: Fri, 03 Aug 2007 17:35:52 -0700

Forwarding to users mailing list.

-------- Original Message --------
Subject: Use of SERIAL and BIGSERIAL w/ EJB3 and POSTGRES
Date: Fri, 03 Aug 2007 17:21:17 -0700
From: Benjamin Renaud <benjamin.renaud_at_gmail.com>
Reply-To: benjamin_at_pobox.com
To: users-owner_at_glassfish.dev.java.net



So, while I am at it, go Glassfish. It's a very nice product and kudos
to Sun and the community for putting it out.

Now for the real issue. To make a long story short, I have several
servers accessing one instance of Postgres.

I have many entities, and I used the Generation.AUTO strategy to
generate my int PK. On one of the entities (the most often used...) I
started getting PK collisions. I figured that the instances are using
the same algorithm and running into trouble.

I want to stop this nonsense and use the DB to generate PKs (I
originally assumed that was what AUTO was doing. Silly me) Postgres has
SERIAL and BIGSERIAL types that does exactly what I want. How do I map
my PK to a BIGSERIAL type? (or SERIAL if BIGSERIAL isn't possible)

And any tips on graceful migration are most welcome :)

Thanks all!