Caches for two separate Classes are identical????

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Caches for two separate Classes are identical????

jtuchel
I am currently having deep trouble with DuplicatePrimaryKeyExceptions in read operations ... ???

The problem is that the Session's Cache contains two subcaches for separate classes that are the same object.

Meaning:

(sess cacheFor: ClassA) == (sess cacheFor: ClassB) evaluates to true.

The DuplicateKey exception happens in a check for isNew: during registration of a TransitiveClosure. It happens because in that Cache there are two instances of classes ClassA and ClassB that have the same primary key. That is why


Cache>>#includesKey: key as: anObject
    "Return true if we include the object, and it matches the given object. If we include a different object with the same key, raise an exception. Don't listen to any expiry policy"

    | item value |

    item := self basicAt: key ifAbsent: [^false].
    value := policy contentsOf: item.
    value == anObject ifFalse: [(DuplicatePrimaryKeyException new: anObject existing: value) signal].
    ^true


fails with a DuplicateKeyException. instanceA is an instance of ClassA and has id=1541 and instanceB us an instance of ClassB and also has id=1541. Glorp assumes thata subcache only contains instances of one class, and that usually is true.
Inpscting the Cache and its subcaches clearly shows that the subcache contains objects from both ClassA and ClassB.

What could I have done wrong? How could I have two subcaches in a Session's Cache that both are the identical object???? I am not messing with Caches in my application code. I know I am not clever enough to change anything "down there"... ;-)


I tried a fresh image and loaded my code into it and the problem still persists.

Any hints? Anybody ever seen this? Where to look?


Joachim

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Caches for two separate Classes are identical????

Esteban A. Maringolo
Hi Joachin,

I had a somewhat related issue when using TypeResolvers for abstract classes.

Where if you had AbstractClass parent of ClassA and ClassB, if you
query ClassA it will end in a Cache instance, but if you query
AbstractClass you'd have another cache instance.

Are you using Hierarchical Type Resolvers?


Regards,



Esteban A. Maringolo


2017-10-10 10:51 GMT-03:00 jtuchel <[hidden email]>:

> I am currently having deep trouble with DuplicatePrimaryKeyExceptions in
> read operations ... ???
>
> The problem is that the Session's Cache contains two subcaches for separate
> classes that are the same object.
>
> Meaning:
>
> (sess cacheFor: ClassA) == (sess cacheFor: ClassB) evaluates to true.
>
> The DuplicateKey exception happens in a check for isNew: during registration
> of a TransitiveClosure. It happens because in that Cache there are two
> instances of classes ClassA and ClassB that have the same primary key. That
> is why
>
>
> Cache>>#includesKey: key as: anObject
>     "Return true if we include the object, and it matches the given object.
> If we include a different object with the same key, raise an exception.
> Don't listen to any expiry policy"
>
>     | item value |
>
>     item := self basicAt: key ifAbsent: [^false].
>     value := policy contentsOf: item.
>     value == anObject ifFalse: [(DuplicatePrimaryKeyException new: anObject
> existing: value) signal].
>     ^true
>
>
> fails with a DuplicateKeyException. instanceA is an instance of ClassA and
> has id=1541 and instanceB us an instance of ClassB and also has id=1541.
> Glorp assumes thata subcache only contains instances of one class, and that
> usually is true.
> Inpscting the Cache and its subcaches clearly shows that the subcache
> contains objects from both ClassA and ClassB.
>
> What could I have done wrong? How could I have two subcaches in a Session's
> Cache that both are the identical object???? I am not messing with Caches in
> my application code. I know I am not clever enough to change anything "down
> there"... ;-)
>
>
> I tried a fresh image and loaded my code into it and the problem still
> persists.
>
> Any hints? Anybody ever seen this? Where to look?
>
>
> Joachim
>
> --
> You received this message because you are subscribed to the Google Groups
> "glorp-group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> To post to this group, send email to [hidden email].
> Visit this group at https://groups.google.com/group/glorp-group.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Caches for two separate Classes are identical????

jtuchel
Esteban,


Yes, these are both Subclasses of an Abstract Class. They live in
distinct tables.
The TypeResolver, however, is a HorizontalTypeResolver.

The mappings which are used to read the instances, are oneToOneMappings
or oneToManyMappings that reference the concrete subclass and table.

Loading of these objects stopped working when I changed the superclass
of ClassA and ClassB from Object to this abstract superclass.

So you are spot on!

Do you have an idea how I could solve the issue?

Thanks,

Joachim





Am 10.10.17 um 16:10 schrieb Esteban A. Maringolo:

> Hi Joachin,
>
> I had a somewhat related issue when using TypeResolvers for abstract classes.
>
> Where if you had AbstractClass parent of ClassA and ClassB, if you
> query ClassA it will end in a Cache instance, but if you query
> AbstractClass you'd have another cache instance.
>
> Are you using Hierarchical Type Resolvers?
>
>
> Regards,
>
>
>
> Esteban A. Maringolo
>
>
> 2017-10-10 10:51 GMT-03:00 jtuchel <[hidden email]>:
>> I am currently having deep trouble with DuplicatePrimaryKeyExceptions in
>> read operations ... ???
>>
>> The problem is that the Session's Cache contains two subcaches for separate
>> classes that are the same object.
>>
>> Meaning:
>>
>> (sess cacheFor: ClassA) == (sess cacheFor: ClassB) evaluates to true.
>>
>> The DuplicateKey exception happens in a check for isNew: during registration
>> of a TransitiveClosure. It happens because in that Cache there are two
>> instances of classes ClassA and ClassB that have the same primary key. That
>> is why
>>
>>
>> Cache>>#includesKey: key as: anObject
>>      "Return true if we include the object, and it matches the given object.
>> If we include a different object with the same key, raise an exception.
>> Don't listen to any expiry policy"
>>
>>      | item value |
>>
>>      item := self basicAt: key ifAbsent: [^false].
>>      value := policy contentsOf: item.
>>      value == anObject ifFalse: [(DuplicatePrimaryKeyException new: anObject
>> existing: value) signal].
>>      ^true
>>
>>
>> fails with a DuplicateKeyException. instanceA is an instance of ClassA and
>> has id=1541 and instanceB us an instance of ClassB and also has id=1541.
>> Glorp assumes thata subcache only contains instances of one class, and that
>> usually is true.
>> Inpscting the Cache and its subcaches clearly shows that the subcache
>> contains objects from both ClassA and ClassB.
>>
>> What could I have done wrong? How could I have two subcaches in a Session's
>> Cache that both are the identical object???? I am not messing with Caches in
>> my application code. I know I am not clever enough to change anything "down
>> there"... ;-)
>>
>>
>> I tried a fresh image and loaded my code into it and the problem still
>> persists.
>>
>> Any hints? Anybody ever seen this? Where to look?
>>
>>
>> Joachim
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "glorp-group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [hidden email].
>> To post to this group, send email to [hidden email].
>> Visit this group at https://groups.google.com/group/glorp-group.
>> For more options, visit https://groups.google.com/d/optout.


--
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:[hidden email]
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Caches for two separate Classes are identical????

jtuchel
In reply to this post by Esteban A. Maringolo
Hi agian, Esteban,

Am 10.10.17 um 16:10 schrieb Esteban A. Maringolo:
> Hi Joachin,
>
> I had a somewhat related issue when using TypeResolvers for abstract classes.
>
> Where if you had AbstractClass parent of ClassA and ClassB, if you
> query ClassA it will end in a Cache instance, but if you query
> AbstractClass you'd have another cache instance.

This is a  bug, isn't it? The cache should be chosen based on the
concrete Class an object is an instance of, no?

My expectation would be that if I do:

session read: AbstractClass where: [:whatever| ]


I would expect the resulting objects to always reside in the caches of
the concrete subclasses... Also I would expect that cache lookups do not
happen in a Cache of the Abstract superclass, but on the concrete
subclasses' subcaches.... Am I wrong?


What's funny in my case is that teh Cache has subcaches for both (and
other) concrete subclasses, but both the subcaches are the very same
(identical) cache object.


Joachim


--
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:[hidden email]
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Caches for two separate Classes are identical????

jtuchel
SOLVED!


Life can be so damn hard. Especially when you find out that you've been looking at all kinds of esoteric options instead of the only obvious thing.

The problem was indeed that in a Cache that holds objects of different classes there were objects with identical duplicate keys. But nothing was wrong with Glorp - it was (again) my fault.

I had changed two classes to be a subclass of an already mapped class which is abstract and already had subclasses. To make a long story short, I completely forgot about the id sequences. The objects in the tables already had ids, and these had been generated by a sequence different from the one of that abstract superclass and all its subclasses, so there had been overlaps.

Glorp had told me so: DuplicatePrimaryException. But I was so blinded by the fact that Glorp reuses a Cache for several classes (which is okay) that I didn't see the obvious.

Now that I did some SQL magic to assign new IDs to my objects, all is well again.


Nevertheless, I think without Esteban's comment, I would possibly have searched for another decade or so ;-) Thanks for your tip, dude!


Joachim



 
--
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:[hidden email]
Fliederweg 1                         <a href="http://www.objektfabrik.de" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.objektfabrik.de\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHeyxMjM5BXvR5qw85qSPuClmpEg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.objektfabrik.de\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHeyxMjM5BXvR5qw85qSPuClmpEg&#39;;return true;">http://www.objektfabrik.de
D-71640 Ludwigsburg                  <a href="http://joachimtuchel.wordpress.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjoachimtuchel.wordpress.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF4lN1gz9j6BhOOltuFRTSnjfL65w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjoachimtuchel.wordpress.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF4lN1gz9j6BhOOltuFRTSnjfL65w&#39;;return true;">http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Caches for two separate Classes are identical????

Esteban A. Maringolo
I'm glad I helped you to narrow the search although the bug wasn't a
Glorp issue per se.

Now you mention I was bitten by a similar issue, after that I made a
lot of helper methods in my DescriptorSystem class that create common
fields such as IDs, name, modification/creation timestamps, etc. So I
can be sure and easily spot when I'm not using the same sequence/ids
for different class in the same resolver.

Regards!

Esteban A. Maringolo


2017-10-11 11:00 GMT-03:00 jtuchel <[hidden email]>:

> SOLVED!
>
>
> Life can be so damn hard. Especially when you find out that you've been
> looking at all kinds of esoteric options instead of the only obvious thing.
>
> The problem was indeed that in a Cache that holds objects of different
> classes there were objects with identical duplicate keys. But nothing was
> wrong with Glorp - it was (again) my fault.
>
> I had changed two classes to be a subclass of an already mapped class which
> is abstract and already had subclasses. To make a long story short, I
> completely forgot about the id sequences. The objects in the tables already
> had ids, and these had been generated by a sequence different from the one
> of that abstract superclass and all its subclasses, so there had been
> overlaps.
>
> Glorp had told me so: DuplicatePrimaryException. But I was so blinded by the
> fact that Glorp reuses a Cache for several classes (which is okay) that I
> didn't see the obvious.
>
> Now that I did some SQL magic to assign new IDs to my objects, all is well
> again.
>
>
> Nevertheless, I think without Esteban's comment, I would possibly have
> searched for another decade or so ;-) Thanks for your tip, dude!
>
>
> Joachim
>
>
>
>
>>
>> --
>> -----------------------------------------------------------------------
>> Objektfabrik Joachim Tuchel          mailto:[hidden email]
>> Fliederweg 1                         http://www.objektfabrik.de
>> D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
>> Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1
>>
> --
> You received this message because you are subscribed to the Google Groups
> "glorp-group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> To post to this group, send email to [hidden email].
> Visit this group at https://groups.google.com/group/glorp-group.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Caches for two separate Classes are identical????

Tom Robinson
One way to avoid this problem is to use a single sequence for all of your primary keys. It means that the numbers in the tables get bigger faster, but it also means that every database object has a unique id. You may have to futz with Glorp a little to do this, but it can save round trips to the database, since you only get seque nce numbers once... It sounds like your application might be beyond the stage where this is doable, but there is always next time.

On Wed, Oct 11, 2017 at 12:09 PM, Esteban A. Maringolo <[hidden email]> wrote:
I'm glad I helped you to narrow the search although the bug wasn't a
Glorp issue per se.

Now you mention I was bitten by a similar issue, after that I made a
lot of helper methods in my DescriptorSystem class that create common
fields such as IDs, name, modification/creation timestamps, etc. So I
can be sure and easily spot when I'm not using the same sequence/ids
for different class in the same resolver.

Regards!

Esteban A. Maringolo


2017-10-11 11:00 GMT-03:00 jtuchel <[hidden email]>:
> SOLVED!
>
>
> Life can be so damn hard. Especially when you find out that you've been
> looking at all kinds of esoteric options instead of the only obvious thing.
>
> The problem was indeed that in a Cache that holds objects of different
> classes there were objects with identical duplicate keys. But nothing was
> wrong with Glorp - it was (again) my fault.
>
> I had changed two classes to be a subclass of an already mapped class which
> is abstract and already had subclasses. To make a long story short, I
> completely forgot about the id sequences. The objects in the tables already
> had ids, and these had been generated by a sequence different from the one
> of that abstract superclass and all its subclasses, so there had been
> overlaps.
>
> Glorp had told me so: DuplicatePrimaryException. But I was so blinded by the
> fact that Glorp reuses a Cache for several classes (which is okay) that I
> didn't see the obvious.
>
> Now that I did some SQL magic to assign new IDs to my objects, all is well
> again.
>
>
> Nevertheless, I think without Esteban's comment, I would possibly have
> searched for another decade or so ;-) Thanks for your tip, dude!
>
>
> Joachim
>
>
>
>
>>
>> --
>> -----------------------------------------------------------------------
>> Objektfabrik Joachim Tuchel          mailto:[hidden email]
>> Fliederweg 1                         http://www.objektfabrik.de
>> D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
>> Telefon: <a href="tel:%2B49%207141%2056%2010%2086%200" value="+4971415610860">+49 7141 56 10 86 0         Fax: <a href="tel:%2B49%207141%2056%2010%2086%201" value="+4971415610861">+49 7141 56 10 86 1
>>
> --
> You received this message because you are subscribed to the Google Groups
> "glorp-group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> To post to this group, send email to [hidden email].
> Visit this group at https://groups.google.com/group/glorp-group.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Caches for two separate Classes are identical????

Esteban A. Maringolo
2017-10-11 13:53 GMT-03:00 Tom Robinson <[hidden email]>:
> One way to avoid this problem is to use a single sequence for all of your
> primary keys. It means that the numbers in the tables get bigger faster, but
> it also means that every database object has a unique id. You may have to
> futz with Glorp a little to do this, but it can save round trips to the
> database, since you only get seque nce numbers once... It sounds like your
> application might be beyond the stage where this is doable, but there is
> always next time.


In another system using Smalltalk with a custom ORM (not Glorp), we
went down that path of using a a GUID/UUID based ID generation.

We avoided some rare ID collisions in the cases that no sequences were
used (or available) and of course saved one extra roundtrip.

The problem was that the end result in terms of database size was
significant, and doing manual queries was a real pain.
I've read that some massive systems create unique IDs by using a shard
ID + timestamp + some random. With all that you can have a more
readable number, that can even be encoded as Hex or any other more
compact representation.

Regards!

Esteban A. Maringolo

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Caches for two separate Classes are identical????

jtuchel
In reply to this post by Esteban A. Maringolo
You see, that's the kind of stuff I was looking for in my other post about getting together: sometimes you just need to learn lessons, and sometimes there is an abbreviation to the process if you have peers who've found out the hard way or learned from another peer.



Am Mittwoch, 11. Oktober 2017 18:10:04 UTC+2 schrieb Esteban A. Maringolo:
I'm glad I helped you to narrow the search although the bug wasn't a
Glorp issue per se.

Now you mention I was bitten by a similar issue, after that I made a
lot of helper methods in my DescriptorSystem class that create common
fields such as IDs, name, modification/creation timestamps, etc. So I
can be sure and easily spot when I'm not using the same sequence/ids
for different class in the same resolver.

Regards!

Esteban A. Maringolo


2017-10-11 11:00 GMT-03:00 jtuchel <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="NVjsBYRGAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jtu...@...>:

> SOLVED!
>
>
> Life can be so damn hard. Especially when you find out that you've been
> looking at all kinds of esoteric options instead of the only obvious thing.
>
> The problem was indeed that in a Cache that holds objects of different
> classes there were objects with identical duplicate keys. But nothing was
> wrong with Glorp - it was (again) my fault.
>
> I had changed two classes to be a subclass of an already mapped class which
> is abstract and already had subclasses. To make a long story short, I
> completely forgot about the id sequences. The objects in the tables already
> had ids, and these had been generated by a sequence different from the one
> of that abstract superclass and all its subclasses, so there had been
> overlaps.
>
> Glorp had told me so: DuplicatePrimaryException. But I was so blinded by the
> fact that Glorp reuses a Cache for several classes (which is okay) that I
> didn't see the obvious.
>
> Now that I did some SQL magic to assign new IDs to my objects, all is well
> again.
>
>
> Nevertheless, I think without Esteban's comment, I would possibly have
> searched for another decade or so ;-) Thanks for your tip, dude!
>
>
> Joachim
>
>
>
>
>>
>> --
>> -----------------------------------------------------------------------
>> Objektfabrik Joachim Tuchel          mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="NVjsBYRGAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jtu...@objektfabrik.de
>> Fliederweg 1                         <a href="http://www.objektfabrik.de" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.objektfabrik.de\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHeyxMjM5BXvR5qw85qSPuClmpEg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.objektfabrik.de\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHeyxMjM5BXvR5qw85qSPuClmpEg&#39;;return true;">http://www.objektfabrik.de
>> D-71640 Ludwigsburg                  <a href="http://joachimtuchel.wordpress.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjoachimtuchel.wordpress.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF4lN1gz9j6BhOOltuFRTSnjfL65w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjoachimtuchel.wordpress.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF4lN1gz9j6BhOOltuFRTSnjfL65w&#39;;return true;">http://joachimtuchel.wordpress.com
>> Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1
>>
> --
> You received this message because you are subscribed to the Google Groups
> "glorp-group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="NVjsBYRGAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">glorp-group...@googlegroups.com.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="NVjsBYRGAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">glorp...@....
> Visit this group at <a href="https://groups.google.com/group/glorp-group" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/glorp-group&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/glorp-group&#39;;return true;">https://groups.google.com/group/glorp-group.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Caches for two separate Classes are identical????

jtuchel
In reply to this post by Tom Robinson
Tom,

You are of course right and your tip/comment is highly appreciated.
Some choices cannot be easily changed for en existing system, unfortunately. I am working on a customer project that uses this approach in TopLink and there are no such problems.


Joachim




Am Mittwoch, 11. Oktober 2017 18:53:17 UTC+2 schrieb Tom Robinson:
One way to avoid this problem is to use a single sequence for all of your primary keys. It means that the numbers in the tables get bigger faster, but it also means that every database object has a unique id. You may have to futz with Glorp a little to do this, but it can save round trips to the database, since you only get seque nce numbers once... It sounds like your application might be beyond the stage where this is doable, but there is always next time.

On Wed, Oct 11, 2017 at 12:09 PM, Esteban A. Maringolo <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="cU_S1d9IAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">emari...@...> wrote:
I'm glad I helped you to narrow the search although the bug wasn't a
Glorp issue per se.

Now you mention I was bitten by a similar issue, after that I made a
lot of helper methods in my DescriptorSystem class that create common
fields such as IDs, name, modification/creation timestamps, etc. So I
can be sure and easily spot when I'm not using the same sequence/ids
for different class in the same resolver.

Regards!

Esteban A. Maringolo


2017-10-11 11:00 GMT-03:00 jtuchel <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="cU_S1d9IAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jtu...@...>:
> SOLVED!
>
>
> Life can be so damn hard. Especially when you find out that you've been
> looking at all kinds of esoteric options instead of the only obvious thing.
>
> The problem was indeed that in a Cache that holds objects of different
> classes there were objects with identical duplicate keys. But nothing was
> wrong with Glorp - it was (again) my fault.
>
> I had changed two classes to be a subclass of an already mapped class which
> is abstract and already had subclasses. To make a long story short, I
> completely forgot about the id sequences. The objects in the tables already
> had ids, and these had been generated by a sequence different from the one
> of that abstract superclass and all its subclasses, so there had been
> overlaps.
>
> Glorp had told me so: DuplicatePrimaryException. But I was so blinded by the
> fact that Glorp reuses a Cache for several classes (which is okay) that I
> didn't see the obvious.
>
> Now that I did some SQL magic to assign new IDs to my objects, all is well
> again.
>
>
> Nevertheless, I think without Esteban's comment, I would possibly have
> searched for another decade or so ;-) Thanks for your tip, dude!
>
>
> Joachim
>
>
>
>
>>
>> --
>> -----------------------------------------------------------------------
>> Objektfabrik Joachim Tuchel          mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="cU_S1d9IAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jtu...@...
>> Fliederweg 1                         <a href="http://www.objektfabrik.de" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.objektfabrik.de\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHeyxMjM5BXvR5qw85qSPuClmpEg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.objektfabrik.de\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHeyxMjM5BXvR5qw85qSPuClmpEg&#39;;return true;">http://www.objektfabrik.de
>> D-71640 Ludwigsburg                  <a href="http://joachimtuchel.wordpress.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjoachimtuchel.wordpress.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF4lN1gz9j6BhOOltuFRTSnjfL65w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjoachimtuchel.wordpress.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF4lN1gz9j6BhOOltuFRTSnjfL65w&#39;;return true;">http://joachimtuchel.wordpress.com
>> Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1
>>
> --
> You received this message because you are subscribed to the Google Groups
> "glorp-group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="cU_S1d9IAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">glorp-group...@googlegroups.com.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="cU_S1d9IAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">glorp...@....
> Visit this group at <a href="https://groups.google.com/group/glorp-group" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/group/glorp-group&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/glorp-group&#39;;return true;">https://groups.google.com/group/glorp-group.
> For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="cU_S1d9IAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">glorp-group...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="cU_S1d9IAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">glorp...@....
Visit this group at <a href="https://groups.google.com/group/glorp-group" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/group/glorp-group&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/glorp-group&#39;;return true;">https://groups.google.com/group/glorp-group.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.