You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Elias Torres <el...@torrez.us> on 2007/07/25 16:12:07 UTC

uuid-string not generating unique ids

Hi,

First off, I want to say thank you for the hard work this community has
put on this JPA implementation. I'm extremely eager in getting to know
it better and hopefully put it to good use in some of the projects I'm
currently working on at IBM. If all goes well, I'll be asking some of
the harder questions later and possibly discuss new features not
currently implemented.

Now if you could please help me out with a small issue I'm having with
uuid generation.

@Entity
public class Foo {

  @Id
  @GeneratedValue(strategy=GenerationType.AUTO, generator="uuid-string")
  private String id;

}

CREATE TABLE Foo (
  id VARCHAR(16) NOT NULL
}

If I do one em.persist() it works just fine. However, if I do a a whole
list of them, I get exceptions (duplicate). If I enable logging I can
see they are all using the same id during INSERT. I stepped a bit
through the code and noticed that uuid-string doesn't get generated
while em.persist(), but much later while committing/flushing. I then
looked a bit (just a bit) at the UUID generator code and noticed that
the bytes are not changing much (maybe only the first two), but again,
that was while debugging, so I'm assuming I have a supa-fast machine.

Anybody running into the same problem? Any suggestions?

-Elias

Re: uuid-string not generating unique ids

Posted by Patrick Linskey <pl...@gmail.com>.
That makes some sense -- I bet you're using multiple cores. Our tests
of the UUIDGenerator are all single-threaded.

-Patrick

On 7/25/07, Elias Torres <el...@torrez.us> wrote:
> It's just my laptop (IBM ThinkPad Core Duo 2.16Ghz).
>
> -Elias
>
> Patrick Linskey wrote:
> > Great! What type of hardware are you running on, btw? We were already
> > doing some testing in a pretty tight loop, but maybe Hotspot was being
> > clever and optimizing it away.
> >
> > -Patrick
> >
> > On 7/25/07, Elias Torres <el...@torrez.us> wrote:
> >> FYI, the patch worked.
> >>
> >> -Elias
> >>
> >> Patrick Linskey wrote:
> >> > There have been a lot of changes since then, but things should be
> >> > pretty compatible.
> >> >
> >> > If you've got a good test suite, I'd recommend switching to trunk and
> >> > seeing what happens.
> >> >
> >> > -Patrick
> >> >
> >> > On 7/25/07, Elias Torres <el...@torrez.us> wrote:
> >> >>
> >> >> Thank you Patrick and Mark. I'm using 0.9.7, so I'm either patching it
> >> >> or switching to trunk. Do you think it'd be safe (for an agile
> >> >> development group) to switch to trunk from 0.9.7 or were there many
> >> big
> >> >> changes since then?
> >> >>
> >> >> Anyways, thanks again. I'll ask a couple of other things later.
> >> >>
> >> >> -Elias
> >> >>
> >> >> Patrick Linskey wrote:
> >> >> > I just committed a change that will maybe resolve the issue. Please
> >> >> > let us know if you see it come up again.
> >> >> >
> >> >> > I also logged the issue as OPENJPA-296.
> >> >> >
> >> >> > -Patrick
> >> >> >
> >> >> > On 7/25/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
> >> >> >> Patrick-
> >> >> >>
> >> >> >> I bet you are right. Your analysis of the problem looks correct
> >> to me.
> >> >> >>
> >> >> >>
> >> >> >> On Jul 25, 2007, at 9:12 AM, Patrick Linskey wrote:
> >> >> >>
> >> >> >> > Hi,
> >> >> >> >
> >> >> >> > Based on a quick read, it looks like maybe the problem is
> >> >> >> > UUIDGenerator.java:178. I suspect that we should be changing
> >> that to
> >> >> >> > obtain another newTime inside the if block after incrementing the
> >> >> >> > sequence. However, I'm not an expert in this algorithm; does
> >> anyone
> >> >> >> > have a better grasp on it than do I?
> >> >> >> >
> >> >> >> > -Patrick
> >> >> >> >
> >> >> >> > On 7/25/07, Elias Torres <el...@torrez.us> wrote:
> >> >> >> >>
> >> >> >> >> Hi,
> >> >> >> >>
> >> >> >> >> First off, I want to say thank you for the hard work this
> >> >> >> >> community has
> >> >> >> >> put on this JPA implementation. I'm extremely eager in
> >> getting to
> >> >> >> >> know
> >> >> >> >> it better and hopefully put it to good use in some of the
> >> projects
> >> >> >> >> I'm
> >> >> >> >> currently working on at IBM. If all goes well, I'll be asking
> >> >> some of
> >> >> >> >> the harder questions later and possibly discuss new features not
> >> >> >> >> currently implemented.
> >> >> >> >>
> >> >> >> >> Now if you could please help me out with a small issue I'm
> >> having
> >> >> >> >> with
> >> >> >> >> uuid generation.
> >> >> >> >>
> >> >> >> >> @Entity
> >> >> >> >> public class Foo {
> >> >> >> >>
> >> >> >> >>   @Id
> >> >> >> >>   @GeneratedValue(strategy=GenerationType.AUTO, generator="uuid-
> >> >> >> >> string")
> >> >> >> >>   private String id;
> >> >> >> >>
> >> >> >> >> }
> >> >> >> >>
> >> >> >> >> CREATE TABLE Foo (
> >> >> >> >>   id VARCHAR(16) NOT NULL
> >> >> >> >> }
> >> >> >> >>
> >> >> >> >> If I do one em.persist() it works just fine. However, if I do
> >> a a
> >> >> >> >> whole
> >> >> >> >> list of them, I get exceptions (duplicate). If I enable logging
> >> >> I can
> >> >> >> >> see they are all using the same id during INSERT. I stepped a
> >> bit
> >> >> >> >> through the code and noticed that uuid-string doesn't get
> >> generated
> >> >> >> >> while em.persist(), but much later while committing/flushing. I
> >> >> then
> >> >> >> >> looked a bit (just a bit) at the UUID generator code and noticed
> >> >> that
> >> >> >> >> the bytes are not changing much (maybe only the first two), but
> >> >> >> >> again,
> >> >> >> >> that was while debugging, so I'm assuming I have a supa-fast
> >> >> machine.
> >> >> >> >>
> >> >> >> >> Anybody running into the same problem? Any suggestions?
> >> >> >> >>
> >> >> >> >> -Elias
> >> >> >> >>
> >> >> >> >
> >> >> >> >
> >> >> >> > --
> >> >> >> > Patrick Linskey
> >> >> >> > 202 669 5907
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >>
> >> >
> >> >
> >>
> >
> >
>


-- 
Patrick Linskey
202 669 5907

Re: uuid-string not generating unique ids

Posted by Elias Torres <el...@torrez.us>.
It's just my laptop (IBM ThinkPad Core Duo 2.16Ghz).

-Elias

Patrick Linskey wrote:
> Great! What type of hardware are you running on, btw? We were already
> doing some testing in a pretty tight loop, but maybe Hotspot was being
> clever and optimizing it away.
> 
> -Patrick
> 
> On 7/25/07, Elias Torres <el...@torrez.us> wrote:
>> FYI, the patch worked.
>>
>> -Elias
>>
>> Patrick Linskey wrote:
>> > There have been a lot of changes since then, but things should be
>> > pretty compatible.
>> >
>> > If you've got a good test suite, I'd recommend switching to trunk and
>> > seeing what happens.
>> >
>> > -Patrick
>> >
>> > On 7/25/07, Elias Torres <el...@torrez.us> wrote:
>> >>
>> >> Thank you Patrick and Mark. I'm using 0.9.7, so I'm either patching it
>> >> or switching to trunk. Do you think it'd be safe (for an agile
>> >> development group) to switch to trunk from 0.9.7 or were there many
>> big
>> >> changes since then?
>> >>
>> >> Anyways, thanks again. I'll ask a couple of other things later.
>> >>
>> >> -Elias
>> >>
>> >> Patrick Linskey wrote:
>> >> > I just committed a change that will maybe resolve the issue. Please
>> >> > let us know if you see it come up again.
>> >> >
>> >> > I also logged the issue as OPENJPA-296.
>> >> >
>> >> > -Patrick
>> >> >
>> >> > On 7/25/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>> >> >> Patrick-
>> >> >>
>> >> >> I bet you are right. Your analysis of the problem looks correct
>> to me.
>> >> >>
>> >> >>
>> >> >> On Jul 25, 2007, at 9:12 AM, Patrick Linskey wrote:
>> >> >>
>> >> >> > Hi,
>> >> >> >
>> >> >> > Based on a quick read, it looks like maybe the problem is
>> >> >> > UUIDGenerator.java:178. I suspect that we should be changing
>> that to
>> >> >> > obtain another newTime inside the if block after incrementing the
>> >> >> > sequence. However, I'm not an expert in this algorithm; does
>> anyone
>> >> >> > have a better grasp on it than do I?
>> >> >> >
>> >> >> > -Patrick
>> >> >> >
>> >> >> > On 7/25/07, Elias Torres <el...@torrez.us> wrote:
>> >> >> >>
>> >> >> >> Hi,
>> >> >> >>
>> >> >> >> First off, I want to say thank you for the hard work this
>> >> >> >> community has
>> >> >> >> put on this JPA implementation. I'm extremely eager in
>> getting to
>> >> >> >> know
>> >> >> >> it better and hopefully put it to good use in some of the
>> projects
>> >> >> >> I'm
>> >> >> >> currently working on at IBM. If all goes well, I'll be asking
>> >> some of
>> >> >> >> the harder questions later and possibly discuss new features not
>> >> >> >> currently implemented.
>> >> >> >>
>> >> >> >> Now if you could please help me out with a small issue I'm
>> having
>> >> >> >> with
>> >> >> >> uuid generation.
>> >> >> >>
>> >> >> >> @Entity
>> >> >> >> public class Foo {
>> >> >> >>
>> >> >> >>   @Id
>> >> >> >>   @GeneratedValue(strategy=GenerationType.AUTO, generator="uuid-
>> >> >> >> string")
>> >> >> >>   private String id;
>> >> >> >>
>> >> >> >> }
>> >> >> >>
>> >> >> >> CREATE TABLE Foo (
>> >> >> >>   id VARCHAR(16) NOT NULL
>> >> >> >> }
>> >> >> >>
>> >> >> >> If I do one em.persist() it works just fine. However, if I do
>> a a
>> >> >> >> whole
>> >> >> >> list of them, I get exceptions (duplicate). If I enable logging
>> >> I can
>> >> >> >> see they are all using the same id during INSERT. I stepped a
>> bit
>> >> >> >> through the code and noticed that uuid-string doesn't get
>> generated
>> >> >> >> while em.persist(), but much later while committing/flushing. I
>> >> then
>> >> >> >> looked a bit (just a bit) at the UUID generator code and noticed
>> >> that
>> >> >> >> the bytes are not changing much (maybe only the first two), but
>> >> >> >> again,
>> >> >> >> that was while debugging, so I'm assuming I have a supa-fast
>> >> machine.
>> >> >> >>
>> >> >> >> Anybody running into the same problem? Any suggestions?
>> >> >> >>
>> >> >> >> -Elias
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >> > --
>> >> >> > Patrick Linskey
>> >> >> > 202 669 5907
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >
>> >
>>
> 
> 

Re: uuid-string not generating unique ids

Posted by Patrick Linskey <pl...@gmail.com>.
Great! What type of hardware are you running on, btw? We were already
doing some testing in a pretty tight loop, but maybe Hotspot was being
clever and optimizing it away.

-Patrick

On 7/25/07, Elias Torres <el...@torrez.us> wrote:
> FYI, the patch worked.
>
> -Elias
>
> Patrick Linskey wrote:
> > There have been a lot of changes since then, but things should be
> > pretty compatible.
> >
> > If you've got a good test suite, I'd recommend switching to trunk and
> > seeing what happens.
> >
> > -Patrick
> >
> > On 7/25/07, Elias Torres <el...@torrez.us> wrote:
> >>
> >> Thank you Patrick and Mark. I'm using 0.9.7, so I'm either patching it
> >> or switching to trunk. Do you think it'd be safe (for an agile
> >> development group) to switch to trunk from 0.9.7 or were there many big
> >> changes since then?
> >>
> >> Anyways, thanks again. I'll ask a couple of other things later.
> >>
> >> -Elias
> >>
> >> Patrick Linskey wrote:
> >> > I just committed a change that will maybe resolve the issue. Please
> >> > let us know if you see it come up again.
> >> >
> >> > I also logged the issue as OPENJPA-296.
> >> >
> >> > -Patrick
> >> >
> >> > On 7/25/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
> >> >> Patrick-
> >> >>
> >> >> I bet you are right. Your analysis of the problem looks correct to me.
> >> >>
> >> >>
> >> >> On Jul 25, 2007, at 9:12 AM, Patrick Linskey wrote:
> >> >>
> >> >> > Hi,
> >> >> >
> >> >> > Based on a quick read, it looks like maybe the problem is
> >> >> > UUIDGenerator.java:178. I suspect that we should be changing that to
> >> >> > obtain another newTime inside the if block after incrementing the
> >> >> > sequence. However, I'm not an expert in this algorithm; does anyone
> >> >> > have a better grasp on it than do I?
> >> >> >
> >> >> > -Patrick
> >> >> >
> >> >> > On 7/25/07, Elias Torres <el...@torrez.us> wrote:
> >> >> >>
> >> >> >> Hi,
> >> >> >>
> >> >> >> First off, I want to say thank you for the hard work this
> >> >> >> community has
> >> >> >> put on this JPA implementation. I'm extremely eager in getting to
> >> >> >> know
> >> >> >> it better and hopefully put it to good use in some of the projects
> >> >> >> I'm
> >> >> >> currently working on at IBM. If all goes well, I'll be asking
> >> some of
> >> >> >> the harder questions later and possibly discuss new features not
> >> >> >> currently implemented.
> >> >> >>
> >> >> >> Now if you could please help me out with a small issue I'm having
> >> >> >> with
> >> >> >> uuid generation.
> >> >> >>
> >> >> >> @Entity
> >> >> >> public class Foo {
> >> >> >>
> >> >> >>   @Id
> >> >> >>   @GeneratedValue(strategy=GenerationType.AUTO, generator="uuid-
> >> >> >> string")
> >> >> >>   private String id;
> >> >> >>
> >> >> >> }
> >> >> >>
> >> >> >> CREATE TABLE Foo (
> >> >> >>   id VARCHAR(16) NOT NULL
> >> >> >> }
> >> >> >>
> >> >> >> If I do one em.persist() it works just fine. However, if I do a a
> >> >> >> whole
> >> >> >> list of them, I get exceptions (duplicate). If I enable logging
> >> I can
> >> >> >> see they are all using the same id during INSERT. I stepped a bit
> >> >> >> through the code and noticed that uuid-string doesn't get generated
> >> >> >> while em.persist(), but much later while committing/flushing. I
> >> then
> >> >> >> looked a bit (just a bit) at the UUID generator code and noticed
> >> that
> >> >> >> the bytes are not changing much (maybe only the first two), but
> >> >> >> again,
> >> >> >> that was while debugging, so I'm assuming I have a supa-fast
> >> machine.
> >> >> >>
> >> >> >> Anybody running into the same problem? Any suggestions?
> >> >> >>
> >> >> >> -Elias
> >> >> >>
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Patrick Linskey
> >> >> > 202 669 5907
> >> >>
> >> >>
> >> >
> >> >
> >>
> >
> >
>


-- 
Patrick Linskey
202 669 5907

Re: uuid-string not generating unique ids

Posted by Elias Torres <el...@torrez.us>.
FYI, the patch worked.

-Elias

Patrick Linskey wrote:
> There have been a lot of changes since then, but things should be
> pretty compatible.
> 
> If you've got a good test suite, I'd recommend switching to trunk and
> seeing what happens.
> 
> -Patrick
> 
> On 7/25/07, Elias Torres <el...@torrez.us> wrote:
>>
>> Thank you Patrick and Mark. I'm using 0.9.7, so I'm either patching it
>> or switching to trunk. Do you think it'd be safe (for an agile
>> development group) to switch to trunk from 0.9.7 or were there many big
>> changes since then?
>>
>> Anyways, thanks again. I'll ask a couple of other things later.
>>
>> -Elias
>>
>> Patrick Linskey wrote:
>> > I just committed a change that will maybe resolve the issue. Please
>> > let us know if you see it come up again.
>> >
>> > I also logged the issue as OPENJPA-296.
>> >
>> > -Patrick
>> >
>> > On 7/25/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>> >> Patrick-
>> >>
>> >> I bet you are right. Your analysis of the problem looks correct to me.
>> >>
>> >>
>> >> On Jul 25, 2007, at 9:12 AM, Patrick Linskey wrote:
>> >>
>> >> > Hi,
>> >> >
>> >> > Based on a quick read, it looks like maybe the problem is
>> >> > UUIDGenerator.java:178. I suspect that we should be changing that to
>> >> > obtain another newTime inside the if block after incrementing the
>> >> > sequence. However, I'm not an expert in this algorithm; does anyone
>> >> > have a better grasp on it than do I?
>> >> >
>> >> > -Patrick
>> >> >
>> >> > On 7/25/07, Elias Torres <el...@torrez.us> wrote:
>> >> >>
>> >> >> Hi,
>> >> >>
>> >> >> First off, I want to say thank you for the hard work this
>> >> >> community has
>> >> >> put on this JPA implementation. I'm extremely eager in getting to
>> >> >> know
>> >> >> it better and hopefully put it to good use in some of the projects
>> >> >> I'm
>> >> >> currently working on at IBM. If all goes well, I'll be asking
>> some of
>> >> >> the harder questions later and possibly discuss new features not
>> >> >> currently implemented.
>> >> >>
>> >> >> Now if you could please help me out with a small issue I'm having
>> >> >> with
>> >> >> uuid generation.
>> >> >>
>> >> >> @Entity
>> >> >> public class Foo {
>> >> >>
>> >> >>   @Id
>> >> >>   @GeneratedValue(strategy=GenerationType.AUTO, generator="uuid-
>> >> >> string")
>> >> >>   private String id;
>> >> >>
>> >> >> }
>> >> >>
>> >> >> CREATE TABLE Foo (
>> >> >>   id VARCHAR(16) NOT NULL
>> >> >> }
>> >> >>
>> >> >> If I do one em.persist() it works just fine. However, if I do a a
>> >> >> whole
>> >> >> list of them, I get exceptions (duplicate). If I enable logging
>> I can
>> >> >> see they are all using the same id during INSERT. I stepped a bit
>> >> >> through the code and noticed that uuid-string doesn't get generated
>> >> >> while em.persist(), but much later while committing/flushing. I
>> then
>> >> >> looked a bit (just a bit) at the UUID generator code and noticed
>> that
>> >> >> the bytes are not changing much (maybe only the first two), but
>> >> >> again,
>> >> >> that was while debugging, so I'm assuming I have a supa-fast
>> machine.
>> >> >>
>> >> >> Anybody running into the same problem? Any suggestions?
>> >> >>
>> >> >> -Elias
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > Patrick Linskey
>> >> > 202 669 5907
>> >>
>> >>
>> >
>> >
>>
> 
> 

Re: uuid-string not generating unique ids

Posted by Elias Torres <el...@torrez.us>.

Patrick Linskey wrote:
> There have been a lot of changes since then, but things should be
> pretty compatible.

Excellent.

> 
> If you've got a good test suite, I'd recommend switching to trunk and
> seeing what happens.

ha! just kidding. I'll give it a try.

-Elias

> 
> -Patrick
> 
> On 7/25/07, Elias Torres <el...@torrez.us> wrote:
>>
>> Thank you Patrick and Mark. I'm using 0.9.7, so I'm either patching it
>> or switching to trunk. Do you think it'd be safe (for an agile
>> development group) to switch to trunk from 0.9.7 or were there many big
>> changes since then?
>>
>> Anyways, thanks again. I'll ask a couple of other things later.
>>
>> -Elias
>>
>> Patrick Linskey wrote:
>> > I just committed a change that will maybe resolve the issue. Please
>> > let us know if you see it come up again.
>> >
>> > I also logged the issue as OPENJPA-296.
>> >
>> > -Patrick
>> >
>> > On 7/25/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>> >> Patrick-
>> >>
>> >> I bet you are right. Your analysis of the problem looks correct to me.
>> >>
>> >>
>> >> On Jul 25, 2007, at 9:12 AM, Patrick Linskey wrote:
>> >>
>> >> > Hi,
>> >> >
>> >> > Based on a quick read, it looks like maybe the problem is
>> >> > UUIDGenerator.java:178. I suspect that we should be changing that to
>> >> > obtain another newTime inside the if block after incrementing the
>> >> > sequence. However, I'm not an expert in this algorithm; does anyone
>> >> > have a better grasp on it than do I?
>> >> >
>> >> > -Patrick
>> >> >
>> >> > On 7/25/07, Elias Torres <el...@torrez.us> wrote:
>> >> >>
>> >> >> Hi,
>> >> >>
>> >> >> First off, I want to say thank you for the hard work this
>> >> >> community has
>> >> >> put on this JPA implementation. I'm extremely eager in getting to
>> >> >> know
>> >> >> it better and hopefully put it to good use in some of the projects
>> >> >> I'm
>> >> >> currently working on at IBM. If all goes well, I'll be asking
>> some of
>> >> >> the harder questions later and possibly discuss new features not
>> >> >> currently implemented.
>> >> >>
>> >> >> Now if you could please help me out with a small issue I'm having
>> >> >> with
>> >> >> uuid generation.
>> >> >>
>> >> >> @Entity
>> >> >> public class Foo {
>> >> >>
>> >> >>   @Id
>> >> >>   @GeneratedValue(strategy=GenerationType.AUTO, generator="uuid-
>> >> >> string")
>> >> >>   private String id;
>> >> >>
>> >> >> }
>> >> >>
>> >> >> CREATE TABLE Foo (
>> >> >>   id VARCHAR(16) NOT NULL
>> >> >> }
>> >> >>
>> >> >> If I do one em.persist() it works just fine. However, if I do a a
>> >> >> whole
>> >> >> list of them, I get exceptions (duplicate). If I enable logging
>> I can
>> >> >> see they are all using the same id during INSERT. I stepped a bit
>> >> >> through the code and noticed that uuid-string doesn't get generated
>> >> >> while em.persist(), but much later while committing/flushing. I
>> then
>> >> >> looked a bit (just a bit) at the UUID generator code and noticed
>> that
>> >> >> the bytes are not changing much (maybe only the first two), but
>> >> >> again,
>> >> >> that was while debugging, so I'm assuming I have a supa-fast
>> machine.
>> >> >>
>> >> >> Anybody running into the same problem? Any suggestions?
>> >> >>
>> >> >> -Elias
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > Patrick Linskey
>> >> > 202 669 5907
>> >>
>> >>
>> >
>> >
>>
> 
> 

Re: uuid-string not generating unique ids

Posted by Patrick Linskey <pl...@gmail.com>.
There have been a lot of changes since then, but things should be
pretty compatible.

If you've got a good test suite, I'd recommend switching to trunk and
seeing what happens.

-Patrick

On 7/25/07, Elias Torres <el...@torrez.us> wrote:
>
> Thank you Patrick and Mark. I'm using 0.9.7, so I'm either patching it
> or switching to trunk. Do you think it'd be safe (for an agile
> development group) to switch to trunk from 0.9.7 or were there many big
> changes since then?
>
> Anyways, thanks again. I'll ask a couple of other things later.
>
> -Elias
>
> Patrick Linskey wrote:
> > I just committed a change that will maybe resolve the issue. Please
> > let us know if you see it come up again.
> >
> > I also logged the issue as OPENJPA-296.
> >
> > -Patrick
> >
> > On 7/25/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
> >> Patrick-
> >>
> >> I bet you are right. Your analysis of the problem looks correct to me.
> >>
> >>
> >> On Jul 25, 2007, at 9:12 AM, Patrick Linskey wrote:
> >>
> >> > Hi,
> >> >
> >> > Based on a quick read, it looks like maybe the problem is
> >> > UUIDGenerator.java:178. I suspect that we should be changing that to
> >> > obtain another newTime inside the if block after incrementing the
> >> > sequence. However, I'm not an expert in this algorithm; does anyone
> >> > have a better grasp on it than do I?
> >> >
> >> > -Patrick
> >> >
> >> > On 7/25/07, Elias Torres <el...@torrez.us> wrote:
> >> >>
> >> >> Hi,
> >> >>
> >> >> First off, I want to say thank you for the hard work this
> >> >> community has
> >> >> put on this JPA implementation. I'm extremely eager in getting to
> >> >> know
> >> >> it better and hopefully put it to good use in some of the projects
> >> >> I'm
> >> >> currently working on at IBM. If all goes well, I'll be asking some of
> >> >> the harder questions later and possibly discuss new features not
> >> >> currently implemented.
> >> >>
> >> >> Now if you could please help me out with a small issue I'm having
> >> >> with
> >> >> uuid generation.
> >> >>
> >> >> @Entity
> >> >> public class Foo {
> >> >>
> >> >>   @Id
> >> >>   @GeneratedValue(strategy=GenerationType.AUTO, generator="uuid-
> >> >> string")
> >> >>   private String id;
> >> >>
> >> >> }
> >> >>
> >> >> CREATE TABLE Foo (
> >> >>   id VARCHAR(16) NOT NULL
> >> >> }
> >> >>
> >> >> If I do one em.persist() it works just fine. However, if I do a a
> >> >> whole
> >> >> list of them, I get exceptions (duplicate). If I enable logging I can
> >> >> see they are all using the same id during INSERT. I stepped a bit
> >> >> through the code and noticed that uuid-string doesn't get generated
> >> >> while em.persist(), but much later while committing/flushing. I then
> >> >> looked a bit (just a bit) at the UUID generator code and noticed that
> >> >> the bytes are not changing much (maybe only the first two), but
> >> >> again,
> >> >> that was while debugging, so I'm assuming I have a supa-fast machine.
> >> >>
> >> >> Anybody running into the same problem? Any suggestions?
> >> >>
> >> >> -Elias
> >> >>
> >> >
> >> >
> >> > --
> >> > Patrick Linskey
> >> > 202 669 5907
> >>
> >>
> >
> >
>


-- 
Patrick Linskey
202 669 5907

Re: uuid-string not generating unique ids

Posted by Elias Torres <el...@torrez.us>.
Thank you Patrick and Mark. I'm using 0.9.7, so I'm either patching it
or switching to trunk. Do you think it'd be safe (for an agile
development group) to switch to trunk from 0.9.7 or were there many big
changes since then?

Anyways, thanks again. I'll ask a couple of other things later.

-Elias

Patrick Linskey wrote:
> I just committed a change that will maybe resolve the issue. Please
> let us know if you see it come up again.
> 
> I also logged the issue as OPENJPA-296.
> 
> -Patrick
> 
> On 7/25/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>> Patrick-
>>
>> I bet you are right. Your analysis of the problem looks correct to me.
>>
>>
>> On Jul 25, 2007, at 9:12 AM, Patrick Linskey wrote:
>>
>> > Hi,
>> >
>> > Based on a quick read, it looks like maybe the problem is
>> > UUIDGenerator.java:178. I suspect that we should be changing that to
>> > obtain another newTime inside the if block after incrementing the
>> > sequence. However, I'm not an expert in this algorithm; does anyone
>> > have a better grasp on it than do I?
>> >
>> > -Patrick
>> >
>> > On 7/25/07, Elias Torres <el...@torrez.us> wrote:
>> >>
>> >> Hi,
>> >>
>> >> First off, I want to say thank you for the hard work this
>> >> community has
>> >> put on this JPA implementation. I'm extremely eager in getting to
>> >> know
>> >> it better and hopefully put it to good use in some of the projects
>> >> I'm
>> >> currently working on at IBM. If all goes well, I'll be asking some of
>> >> the harder questions later and possibly discuss new features not
>> >> currently implemented.
>> >>
>> >> Now if you could please help me out with a small issue I'm having
>> >> with
>> >> uuid generation.
>> >>
>> >> @Entity
>> >> public class Foo {
>> >>
>> >>   @Id
>> >>   @GeneratedValue(strategy=GenerationType.AUTO, generator="uuid-
>> >> string")
>> >>   private String id;
>> >>
>> >> }
>> >>
>> >> CREATE TABLE Foo (
>> >>   id VARCHAR(16) NOT NULL
>> >> }
>> >>
>> >> If I do one em.persist() it works just fine. However, if I do a a
>> >> whole
>> >> list of them, I get exceptions (duplicate). If I enable logging I can
>> >> see they are all using the same id during INSERT. I stepped a bit
>> >> through the code and noticed that uuid-string doesn't get generated
>> >> while em.persist(), but much later while committing/flushing. I then
>> >> looked a bit (just a bit) at the UUID generator code and noticed that
>> >> the bytes are not changing much (maybe only the first two), but
>> >> again,
>> >> that was while debugging, so I'm assuming I have a supa-fast machine.
>> >>
>> >> Anybody running into the same problem? Any suggestions?
>> >>
>> >> -Elias
>> >>
>> >
>> >
>> > --
>> > Patrick Linskey
>> > 202 669 5907
>>
>>
> 
> 

Re: uuid-string not generating unique ids

Posted by Patrick Linskey <pl...@gmail.com>.
I just committed a change that will maybe resolve the issue. Please
let us know if you see it come up again.

I also logged the issue as OPENJPA-296.

-Patrick

On 7/25/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
> Patrick-
>
> I bet you are right. Your analysis of the problem looks correct to me.
>
>
> On Jul 25, 2007, at 9:12 AM, Patrick Linskey wrote:
>
> > Hi,
> >
> > Based on a quick read, it looks like maybe the problem is
> > UUIDGenerator.java:178. I suspect that we should be changing that to
> > obtain another newTime inside the if block after incrementing the
> > sequence. However, I'm not an expert in this algorithm; does anyone
> > have a better grasp on it than do I?
> >
> > -Patrick
> >
> > On 7/25/07, Elias Torres <el...@torrez.us> wrote:
> >>
> >> Hi,
> >>
> >> First off, I want to say thank you for the hard work this
> >> community has
> >> put on this JPA implementation. I'm extremely eager in getting to
> >> know
> >> it better and hopefully put it to good use in some of the projects
> >> I'm
> >> currently working on at IBM. If all goes well, I'll be asking some of
> >> the harder questions later and possibly discuss new features not
> >> currently implemented.
> >>
> >> Now if you could please help me out with a small issue I'm having
> >> with
> >> uuid generation.
> >>
> >> @Entity
> >> public class Foo {
> >>
> >>   @Id
> >>   @GeneratedValue(strategy=GenerationType.AUTO, generator="uuid-
> >> string")
> >>   private String id;
> >>
> >> }
> >>
> >> CREATE TABLE Foo (
> >>   id VARCHAR(16) NOT NULL
> >> }
> >>
> >> If I do one em.persist() it works just fine. However, if I do a a
> >> whole
> >> list of them, I get exceptions (duplicate). If I enable logging I can
> >> see they are all using the same id during INSERT. I stepped a bit
> >> through the code and noticed that uuid-string doesn't get generated
> >> while em.persist(), but much later while committing/flushing. I then
> >> looked a bit (just a bit) at the UUID generator code and noticed that
> >> the bytes are not changing much (maybe only the first two), but
> >> again,
> >> that was while debugging, so I'm assuming I have a supa-fast machine.
> >>
> >> Anybody running into the same problem? Any suggestions?
> >>
> >> -Elias
> >>
> >
> >
> > --
> > Patrick Linskey
> > 202 669 5907
>
>


-- 
Patrick Linskey
202 669 5907

Re: uuid-string not generating unique ids

Posted by Marc Prud'hommeaux <mp...@apache.org>.
Patrick-

I bet you are right. Your analysis of the problem looks correct to me.


On Jul 25, 2007, at 9:12 AM, Patrick Linskey wrote:

> Hi,
>
> Based on a quick read, it looks like maybe the problem is
> UUIDGenerator.java:178. I suspect that we should be changing that to
> obtain another newTime inside the if block after incrementing the
> sequence. However, I'm not an expert in this algorithm; does anyone
> have a better grasp on it than do I?
>
> -Patrick
>
> On 7/25/07, Elias Torres <el...@torrez.us> wrote:
>>
>> Hi,
>>
>> First off, I want to say thank you for the hard work this  
>> community has
>> put on this JPA implementation. I'm extremely eager in getting to  
>> know
>> it better and hopefully put it to good use in some of the projects  
>> I'm
>> currently working on at IBM. If all goes well, I'll be asking some of
>> the harder questions later and possibly discuss new features not
>> currently implemented.
>>
>> Now if you could please help me out with a small issue I'm having  
>> with
>> uuid generation.
>>
>> @Entity
>> public class Foo {
>>
>>   @Id
>>   @GeneratedValue(strategy=GenerationType.AUTO, generator="uuid- 
>> string")
>>   private String id;
>>
>> }
>>
>> CREATE TABLE Foo (
>>   id VARCHAR(16) NOT NULL
>> }
>>
>> If I do one em.persist() it works just fine. However, if I do a a  
>> whole
>> list of them, I get exceptions (duplicate). If I enable logging I can
>> see they are all using the same id during INSERT. I stepped a bit
>> through the code and noticed that uuid-string doesn't get generated
>> while em.persist(), but much later while committing/flushing. I then
>> looked a bit (just a bit) at the UUID generator code and noticed that
>> the bytes are not changing much (maybe only the first two), but  
>> again,
>> that was while debugging, so I'm assuming I have a supa-fast machine.
>>
>> Anybody running into the same problem? Any suggestions?
>>
>> -Elias
>>
>
>
> -- 
> Patrick Linskey
> 202 669 5907


Re: uuid-string not generating unique ids

Posted by Patrick Linskey <pl...@gmail.com>.
Hi,

Based on a quick read, it looks like maybe the problem is
UUIDGenerator.java:178. I suspect that we should be changing that to
obtain another newTime inside the if block after incrementing the
sequence. However, I'm not an expert in this algorithm; does anyone
have a better grasp on it than do I?

-Patrick

On 7/25/07, Elias Torres <el...@torrez.us> wrote:
>
> Hi,
>
> First off, I want to say thank you for the hard work this community has
> put on this JPA implementation. I'm extremely eager in getting to know
> it better and hopefully put it to good use in some of the projects I'm
> currently working on at IBM. If all goes well, I'll be asking some of
> the harder questions later and possibly discuss new features not
> currently implemented.
>
> Now if you could please help me out with a small issue I'm having with
> uuid generation.
>
> @Entity
> public class Foo {
>
>   @Id
>   @GeneratedValue(strategy=GenerationType.AUTO, generator="uuid-string")
>   private String id;
>
> }
>
> CREATE TABLE Foo (
>   id VARCHAR(16) NOT NULL
> }
>
> If I do one em.persist() it works just fine. However, if I do a a whole
> list of them, I get exceptions (duplicate). If I enable logging I can
> see they are all using the same id during INSERT. I stepped a bit
> through the code and noticed that uuid-string doesn't get generated
> while em.persist(), but much later while committing/flushing. I then
> looked a bit (just a bit) at the UUID generator code and noticed that
> the bytes are not changing much (maybe only the first two), but again,
> that was while debugging, so I'm assuming I have a supa-fast machine.
>
> Anybody running into the same problem? Any suggestions?
>
> -Elias
>


-- 
Patrick Linskey
202 669 5907