users
[Top] [All Lists]

Re: [cinjug-users] Hibernate - increment generator

To: "James Carman" <james@xxxxxxxxxxxxxxxxxxxx>
Subject: Re: [cinjug-users] Hibernate - increment generator
From: Kumar <kumarkakani@xxxxxxxxx>
Date: Wed, 12 Sep 2007 13:59:14 -0400
Cc: saki <saki@xxxxxxxx>, users@xxxxxxxxxx
Delivered-to: mailing list users@xxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=umm18+lcKKnUQ/0rqw02lV9UN79TcnerTlpfpt9dYBQ=; b=P4g4dL+6CGl/pLX/tKTT6r4rHuknPkHdSSPmMhsLlxgI9/4LIKfJcBChdLoeuSF349dbWjybSHeAQFjVl3RkXrIA9B98GlqwUgayDPkVuJp+516TgPlcCvwa2fv2Yc2mSXGLYQZfwmRv9X1osuLOl+8WJTkTvlszBJcJjH1+FE0=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=o8V6dZMfk3bF6y+8GfeHHlxfViOCXPQMeYDAq33ukjLYyAxYJhFngirGiwytyujDAjYnfmnprxg+ZF6pjmI9bsi5majxV1BZRs9bZga7gGTMi4kwliJiijJ/1xXwXVTq9beGp0aX/tswd7by/l8IVTkrrJsqATRf1aGTR44ONM8=
In-reply-to: <f2e8eedf0709120958x4066e7cfidcdc65f1d0d10b18@xxxxxxxxxxxxxx>
Mailing-list: contact users-help@xxxxxxxxxx; run by ezmlm
References: <4e2988cc0703130757w58163019sd93564990f48f142@xxxxxxxxxxxxxx> <12639733.post@xxxxxxxxxxxxxxx> <f2e8eedf0709120958x4066e7cfidcdc65f1d0d10b18@xxxxxxxxxxxxxx>
Yes, we tried sequence objects first, which worked locally (But it did not workout in our production environment because we were using an older version of DB2. We also tried identity columns which worked fine, but back-up and other maintenance stuff on the database was difficult, according to our DBA.)

So we tried UUID and it worked perfectly alright. And yes, it solved a lot of our problems too, with multiple apps like (.NET, COBOL and even other Java apps) inserting rows to the same tables.

Thanks for the replies folks! This forum helped us a lot.

Kumar

On 9/12/07, James Carman <james@xxxxxxxxxxxxxxxxxxxx> wrote:
Have you tried using a UUID instead?  That solved a LOT of our problems!

On 9/12/07, saki <saki@xxxxxxxx> wrote:
>
> Probably to late, but may be it will help ...
>
> Per doc this generator should not be used in multiprocess enviroment. It's
> not entirely clear from the doc, but if you look at code, you would find out
> the generator reads the value from database only first time when it is used
> and than it only every time increments this value ...
>
> "increment generates identifiers of type long, short or int that are unique
> only when no other process is inserting data into the same table. Do not use
> in a cluster."
>
>
>
>
> Kumar-10 wrote:
> >
> > I have a question related to Hibernate (I am not sure if this is the right
> > forum to ask this. Please direct me to the right one if so).
> >
> > We have a web application that uses Hibernate's increment generator to
> > insert rows in DB2 tables. We have another Java application that inserts
> > rows in the same DB2 tables using Hibernate's increment generator. These
> > two
> > applications are totally independent of each other and both have mappings
> > like so:
> >
> > <id name="objectId" type="int" column="TABLE_ID">
> >             <generator class="increment"/>
> > </id>
> >
> > My question is: If both applications simultaneously try to insert rows
> > into
> > the same table, will we get a ConstraintViolationException? I read that
> > the
> > increment generator should not be used in a clustered environment (
> > http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html ). I am
> > curious to know how Hibernate works internally. Does it lock the database
> > until it generates the max. id and finishes inserting the corresponding
> > row
> > - all in one transaction?
> >
> > Ideally, I guess we should have had the the database generate sequence
> > numbers and use Hibernate's sequence generator. But at this point, I think
> > it's a bit too late to make such a big change unless absolutely required.
> >
> > Please advise. Thanks in advance as always.
> >
> > Kumar
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Hibernate---increment-generator-tf3396487.html#a12639733
> Sent from the CinJUG - Users mailing list archive at Nabble.com.
>
>
> ---------
> You may unsubscribe from this mailing list
> by sending a blank email addressed to:
> users-unsubscribe@xxxxxxxxxx
>
> --
> Find additional help by sending a blank email
> addressed to:
> users-help@xxxxxxxxxx
>
>

---------
You may unsubscribe from this mailing list
by sending a blank email addressed to:
users-unsubscribe@xxxxxxxxxx

--
Find additional help by sending a blank email
addressed to:
users-help@xxxxxxxxxx


<Prev in Thread] Current Thread [Next in Thread>