Problem with bi-directional mappings and sequence

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

Problem with bi-directional mappings and sequence

Mariano Martinez Peck
Hi,

I am using Glorp with PostgreSQL in Pharo with the native client. All my classes/tables have an ID with a sequence. I have a bi-directional OneToMany relation and I have problems with the IDs generated from the sequences. 

The tables involved is DpAssetIdentification that has a OneToMany relation to DpSecurityTickerSymbolAssociation. Both have a secuence ID and I want the relation from both sides. The problem arises when I try to commit several DpAssetIdentification and somehow, the ID the object gets is a repeated (already existing ID). The problem seems very very similar to: https://groups.google.com/forum/?fromgroups#!msg/glorp-group/iZ6NlGfuiKg/PQ8Z3ikJC00J  but the fix proposed at the end doesn't work for me.

What is funny is that if I remove the all the OneToMany from DpAssetIdentification, it works...

I paste the mappings just in case someone can help me. 
Thanks a lot in advance,


classModelForDpAssetIdentification: aClassModel
...
aClassModel newAttributeNamed: #securityTickerSymbolHistory collectionOf: DpSecurityTickerSymbolAssociation.
...

----

descriptorForDpAssetIdentification: aDescriptor
...
(aDescriptor newMapping: OneToManyMapping)
attributeName: #securityTickerSymbolHistory;
join: (Join
from: (table fieldNamed: 'ID')
to: ((self tableNamed: 'DP_SECURITY_TICKER_SYMBOL_ASSOCIATION') fieldNamed: 'ASSET_IDENTIFICATION_ID')).
...

----

classModelForDpSecurityTickerSymbolAssociation: aClassModel
...
aClassModel newAttributeNamed: #assetIdentification type: DpAssetIdentification.
...

---

descriptorForDpSecurityTickerSymbolAssociation: aDescriptor
....
(aDescriptor newMapping: OneToOneMapping) 
attributeName: #assetIdentification.
....

----

tableForDP_SECURITY_TICKER_SYMBOL_ASSOCIATION: table
| assetIdentificationID |
(table createFieldNamed: 'ID' type: platform sequence) bePrimaryKey.
assetIdentificationID := table createFieldNamed: 'ASSET_IDENTIFICATION_ID' type: platform int4.
table addForeignKeyFrom: assetIdentificationID
to: ((self tableNamed: 'DP_ASSET_IDENTIFICATION') fieldNamed: 'ID').
....

----



--
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 http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Problem with bi-directional mappings and sequence

Alan Knight-2
I don't see anything obviously wrong from your descriptors, though you
did omit a few things. I assume that ID is a sequence in asset
identification, and that table does refer to the right table.

The general issue in the thread you mention is that an attribute is
getting set from two different places. So if something else is setting
the ASSET_IDENTIFICATION_ID field that might explain it. Or do you
have the same security-ticker-symbol-association referenced from
multiple asset identifications? That might cause the value to get set
from one owner and then propogated to the other owner if it was also
new.

  One thing you might try is making an example where you force the IDs
of the asset identifications rather than letting them be generated. If
you explicitly set them as a value, and then something else tries to
make it a different value, you'll get an exception. It might not be an
easy one to understand, but basically you should see a mapping trying
to set a value that's already set. You can also set debugWrite: on a
mapping to get a debugger every time it writes, which might be
helpful, though again it can be tricky to understand. But possibly the
easist is to look for any other mappings that involve the ID of asset
identification or ASSET_IDENTIFICATION_ID.

Alan

On 19 June 2013 08:57, Mariano Martinez Peck <[hidden email]> wrote:

> Hi,
>
> I am using Glorp with PostgreSQL in Pharo with the native client. All my
> classes/tables have an ID with a sequence. I have a bi-directional OneToMany
> relation and I have problems with the IDs generated from the sequences.
>
> The tables involved is DpAssetIdentification that has a OneToMany relation
> to DpSecurityTickerSymbolAssociation. Both have a secuence ID and I want the
> relation from both sides. The problem arises when I try to commit several
> DpAssetIdentification and somehow, the ID the object gets is a repeated
> (already existing ID). The problem seems very very similar to:
> https://groups.google.com/forum/?fromgroups#!msg/glorp-group/iZ6NlGfuiKg/PQ8Z3ikJC00J
> but the fix proposed at the end doesn't work for me.
>
> What is funny is that if I remove the all the OneToMany from
> DpAssetIdentification, it works...
>
> I paste the mappings just in case someone can help me.
> Thanks a lot in advance,
>
>
> classModelForDpAssetIdentification: aClassModel
> ...
> aClassModel newAttributeNamed: #securityTickerSymbolHistory collectionOf:
> DpSecurityTickerSymbolAssociation.
> ...
>
> ----
>
> descriptorForDpAssetIdentification: aDescriptor
> ...
> (aDescriptor newMapping: OneToManyMapping)
> attributeName: #securityTickerSymbolHistory;
> join: (Join
> from: (table fieldNamed: 'ID')
> to: ((self tableNamed: 'DP_SECURITY_TICKER_SYMBOL_ASSOCIATION') fieldNamed:
> 'ASSET_IDENTIFICATION_ID')).
> ...
>
> ----
>
> classModelForDpSecurityTickerSymbolAssociation: aClassModel
> ...
> aClassModel newAttributeNamed: #assetIdentification type:
> DpAssetIdentification.
> ...
>
> ---
>
> descriptorForDpSecurityTickerSymbolAssociation: aDescriptor
> ....
> (aDescriptor newMapping: OneToOneMapping)
> attributeName: #assetIdentification.
> ....
>
> ----
>
> tableForDP_SECURITY_TICKER_SYMBOL_ASSOCIATION: table
> | assetIdentificationID |
> (table createFieldNamed: 'ID' type: platform sequence) bePrimaryKey.
> assetIdentificationID := table createFieldNamed: 'ASSET_IDENTIFICATION_ID'
> type: platform int4.
> table addForeignKeyFrom: assetIdentificationID
> to: ((self tableNamed: 'DP_ASSET_IDENTIFICATION') fieldNamed: 'ID').
> ....
>
> ----
>
>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
> --
> 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 http://groups.google.com/group/glorp-group.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
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 http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: Problem with bi-directional mappings and sequence

Mariano Martinez Peck



On Wed, Jun 19, 2013 at 1:23 PM, Alan Knight <[hidden email]> wrote:
I don't see anything obviously wrong from your descriptors, though you
did omit a few things. I assume that ID is a sequence in asset
identification, and that table does refer to the right table.

Hi Alan,

Yes, I tried to only submit the important data. 
All ids are created with the same code:
(table createFieldNamed: 'ID' type: platform sequence) bePrimaryKey.

And yes, the seem to refer to the right table. 
 

The general issue in the thread you mention is that an attribute is
getting set from two different places. So if something else is setting
the ASSET_IDENTIFICATION_ID field that might explain it.

Well, I MIGHT be setting it from two different places. In #descriptorForDpAssetIdentification:   (as shown in the first email)
I define the OneToMany relation:

(aDescriptor newMapping: OneToManyMapping)
attributeName: #securityTickerSymbolHistory;
join: (Join
from: (table fieldNamed: 'ID')
to: ((self tableNamed: 'DP_SECURITY_TICKER_SYMBOL_ASSOCIATION') fieldNamed: 'ASSET_IDENTIFICATION_ID')).


(If I comment this part, it works, that's why I am sure it is related to this mapping). 

While from the other hand, in #tableForDP_SECURITY_TICKER_SYMBOL_ASSOCIATION:   
I define the FK:

assetIdentificationID := table createFieldNamed: 'ASSET_IDENTIFICATION_ID' type: platform int4.
table addForeignKeyFrom: assetIdentificationID
to: ((self tableNamed: 'DP_ASSET_IDENTIFICATION') fieldNamed: 'ID').

And finally, in #descriptorForDpSecurityTickerSymbolAssociation:  I also have the OneToOne mapping:

(aDescriptor newMapping: OneToOneMapping) 
attributeName: #assetIdentification.


But I guess that's expected if you want a bi-directional mapping, right?

 
Or do you
have the same security-ticker-symbol-association referenced from
multiple asset identifications? That might cause the value to get set
from one owner and then propogated to the other owner if it was also
new.

It seems I don't:

|assets|
assets := DpAssetIdentification allInstances.
DpSecurityTickerSymbolAssociation allInstances do:  [ :each |
(assets select: [ :each2 | each2  securityTickerSymbolHistory includes: each] ) size > 1 ifTrue: [ self halt. ] ]

I get no halt.
 

  One thing you might try is making an example where you force the IDs
of the asset identifications rather than letting them be generated. If
you explicitly set them as a value, and then something else tries to
make it a different value, you'll get an exception. It might not be an
easy one to understand, but basically you should see a mapping trying
to set a value that's already set.

OK, that could be a good test.
But I DO GET NOW (and this is in fact the problem) is that I have a session in which I try to commit all instances (I am populating the DB from scratch with a bunch of objects...they are all new and all have nil IDs). What happens is that I get an exception because I get a duplicate pk. And I inspect the SQL for the insert (which in fact inserts ALL objects) I get (in different places of the insert) something like this:


xxxx .... (ID,ASSET_DESCRIPTION,ASSET_IDENTIFIER,CUSIP,ISIN,EXPIRATION_DATE,MULTIPLIER,IS_FOREIGN_SECURITY,ASSET_CLASS_NAME_ID,SECURITY_CLASS_NAME_ID,CIK_ENTITY_ID)  VALUES (44,'' ...... XXX)

xxxx .... (ID,ASSET_DESCRIPTION,ASSET_IDENTIFIER,CUSIP,ISIN,EXPIRATION_DATE,MULTIPLIER,IS_FOREIGN_SECURITY,ASSET_CLASS_NAME_ID,SECURITY_CLASS_NAME_ID,CIK_ENTITY_ID)  VALUES (44,'' ...... YYY)

and this second raw appears at a weird place. For example, it appears in the raw between the one that gets ID 283 and 284. And then again another raw with also the 44 as ID but a raw between generates IDs of 356 and 357.
So this ID 44 appears in 3 raws in total. Then I also have another number 168 that appears in 2, and 268 that also appears in 2. 

 
You can also set debugWrite: on a
mapping to get a debugger every time it writes, which might be
helpful, though again it can be tricky to understand.

Ok, I will give it a try. 
 
But possibly the
easist is to look for any other mappings that involve the ID of asset
identification or ASSET_IDENTIFICATION_ID.


Ok, let me know if there is anything else I can send to you.

Thanks Alan! 
 

Alan

On 19 June 2013 08:57, Mariano Martinez Peck <[hidden email]> wrote:
> Hi,
>
> I am using Glorp with PostgreSQL in Pharo with the native client. All my
> classes/tables have an ID with a sequence. I have a bi-directional OneToMany
> relation and I have problems with the IDs generated from the sequences.
>
> The tables involved is DpAssetIdentification that has a OneToMany relation
> to DpSecurityTickerSymbolAssociation. Both have a secuence ID and I want the
> relation from both sides. The problem arises when I try to commit several
> DpAssetIdentification and somehow, the ID the object gets is a repeated
> (already existing ID). The problem seems very very similar to:
> https://groups.google.com/forum/?fromgroups#!msg/glorp-group/iZ6NlGfuiKg/PQ8Z3ikJC00J
> but the fix proposed at the end doesn't work for me.
>
> What is funny is that if I remove the all the OneToMany from
> DpAssetIdentification, it works...
>
> I paste the mappings just in case someone can help me.
> Thanks a lot in advance,
>
>
> classModelForDpAssetIdentification: aClassModel
> ...
> aClassModel newAttributeNamed: #securityTickerSymbolHistory collectionOf:
> DpSecurityTickerSymbolAssociation.
> ...
>
> ----
>
> descriptorForDpAssetIdentification: aDescriptor
> ...
> (aDescriptor newMapping: OneToManyMapping)
> attributeName: #securityTickerSymbolHistory;
> join: (Join
> from: (table fieldNamed: 'ID')
> to: ((self tableNamed: 'DP_SECURITY_TICKER_SYMBOL_ASSOCIATION') fieldNamed:
> 'ASSET_IDENTIFICATION_ID')).
> ...
>
> ----
>
> classModelForDpSecurityTickerSymbolAssociation: aClassModel
> ...
> aClassModel newAttributeNamed: #assetIdentification type:
> DpAssetIdentification.
> ...
>
> ---
>
> descriptorForDpSecurityTickerSymbolAssociation: aDescriptor
> ....
> (aDescriptor newMapping: OneToOneMapping)
> attributeName: #assetIdentification.
> ....
>
> ----
>
> tableForDP_SECURITY_TICKER_SYMBOL_ASSOCIATION: table
> | assetIdentificationID |
> (table createFieldNamed: 'ID' type: platform sequence) bePrimaryKey.
> assetIdentificationID := table createFieldNamed: 'ASSET_IDENTIFICATION_ID'
> type: platform int4.
> table addForeignKeyFrom: assetIdentificationID
> to: ((self tableNamed: 'DP_ASSET_IDENTIFICATION') fieldNamed: 'ID').
> ....
>
> ----
>
>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
> --
> 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 http://groups.google.com/group/glorp-group.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
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 http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.





--
Mariano
http://marianopeck.wordpress.com

--
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 http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Problem with bi-directional mappings and sequence

Mariano Martinez Peck
In reply to this post by Alan Knight-2



  One thing you might try is making an example where you force the IDs
of the asset identifications rather than letting them be generated.

Ok I did this. I changed the mapping to use a normal platform int4 and I set the IDs by hand before saving them.
 
If
you explicitly set them as a value, and then something else tries to
make it a different value, you'll get an exception. It might not be an
easy one to understand, but basically you should see a mapping trying
to set a value that's already set.

This is what I am getting. Its 'Inconsistent values in field'. This is a DirectMapping for ID which is trying the set id. 
If I see the variables in #mapFromObject: anObject toTarget: target puttingRowsIn: aRowMap  
everything looks ok: target and anObject id are fine. 
The problem is the row that is answered by "aRowMap findOrAddRowForTable: self field table withKey: target."
is a weird object... :

a DatabaseRow(DP_ASSET_IDENTIFICATION)
    Field(DP_ASSET_IDENTIFICATION.ASSET_DESCRIPTION)->an Object
    Field(DP_ASSET_IDENTIFICATION.ASSET_IDENTIFIER)->an Object
    Field(DP_ASSET_IDENTIFICATION.CUSIP)->an Object
    Field(DP_ASSET_IDENTIFICATION.ISIN)->an Object
    Field(DP_ASSET_IDENTIFICATION.EXPIRATION_DATE)->an Object
    Field(DP_ASSET_IDENTIFICATION.MULTIPLIER)->an Object
    Field(DP_ASSET_IDENTIFICATION.IS_FOREIGN_SECURITY)->an Object
    Field(DP_ASSET_IDENTIFICATION.ASSET_CLASS_NAME_ID)->an Object
    Field(DP_ASSET_IDENTIFICATION.SECURITY_CLASS_NAME_ID)->an Object
    Field(DP_ASSET_IDENTIFICATION.CIK_ENTITY_ID)->an Object


There...that ID 56 is different to 'anObject' and 'target' id, which is 220. 

 mmmmmm

and...remember that if I remove the all the mappings from DpAssetIdentification to DpSecurityTickerSymbolAssociation it works....

I attach the PharoDebug.log just in case.

Thanks in advance!

You can also set debugWrite: on a
mapping to get a debugger every time it writes, which might be
helpful, though again it can be tricky to understand. But possibly the
easist is to look for any other mappings that involve the ID of asset
identification or ASSET_IDENTIFICATION_ID.

Alan

On 19 June 2013 08:57, Mariano Martinez Peck <[hidden email]> wrote:
> Hi,
>
> I am using Glorp with PostgreSQL in Pharo with the native client. All my
> classes/tables have an ID with a sequence. I have a bi-directional OneToMany
> relation and I have problems with the IDs generated from the sequences.
>
> The tables involved is DpAssetIdentification that has a OneToMany relation
> to DpSecurityTickerSymbolAssociation. Both have a secuence ID and I want the
> relation from both sides. The problem arises when I try to commit several
> DpAssetIdentification and somehow, the ID the object gets is a repeated
> (already existing ID). The problem seems very very similar to:
> https://groups.google.com/forum/?fromgroups#!msg/glorp-group/iZ6NlGfuiKg/PQ8Z3ikJC00J
> but the fix proposed at the end doesn't work for me.
>
> What is funny is that if I remove the all the OneToMany from
> DpAssetIdentification, it works...
>
> I paste the mappings just in case someone can help me.
> Thanks a lot in advance,
>
>
> classModelForDpAssetIdentification: aClassModel
> ...
> aClassModel newAttributeNamed: #securityTickerSymbolHistory collectionOf:
> DpSecurityTickerSymbolAssociation.
> ...
>
> ----
>
> descriptorForDpAssetIdentification: aDescriptor
> ...
> (aDescriptor newMapping: OneToManyMapping)
> attributeName: #securityTickerSymbolHistory;
> join: (Join
> from: (table fieldNamed: 'ID')
> to: ((self tableNamed: 'DP_SECURITY_TICKER_SYMBOL_ASSOCIATION') fieldNamed:
> 'ASSET_IDENTIFICATION_ID')).
> ...
>
> ----
>
> classModelForDpSecurityTickerSymbolAssociation: aClassModel
> ...
> aClassModel newAttributeNamed: #assetIdentification type:
> DpAssetIdentification.
> ...
>
> ---
>
> descriptorForDpSecurityTickerSymbolAssociation: aDescriptor
> ....
> (aDescriptor newMapping: OneToOneMapping)
> attributeName: #assetIdentification.
> ....
>
> ----
>
> tableForDP_SECURITY_TICKER_SYMBOL_ASSOCIATION: table
> | assetIdentificationID |
> (table createFieldNamed: 'ID' type: platform sequence) bePrimaryKey.
> assetIdentificationID := table createFieldNamed: 'ASSET_IDENTIFICATION_ID'
> type: platform int4.
> table addForeignKeyFrom: assetIdentificationID
> to: ((self tableNamed: 'DP_ASSET_IDENTIFICATION') fieldNamed: 'ID').
> ....
>
> ----
>
>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
> --
> 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 http://groups.google.com/group/glorp-group.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
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 http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.





--
Mariano
http://marianopeck.wordpress.com

--
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 http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

PharoDebug.log (31K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem with bi-directional mappings and sequence

Alan Knight-2
The "an Object" is a placeholder that means a value hasn't been set.
So you get inconsistent values in a field if two different mappings
try to set the value. Which can be extra-confusing, because some
mappings don't actually set the value, they just indicate that the
value in this field has to be the same as the value in some other
field. e.g. my ID field and somebody elses OWNER_ID field. So when one
of those gets set, the other one is automatically set. So what's
interesting there is that you have a direct mapping that's trying to
set it to one value, but it's already got another value from somewhere
else. And the question is why those two mappings disagree. The direct
mapping presumably has that value because you set it there. But why
does the other mapping think it's something different. If you look a
the DatabaseRow, the internals are FieldValueWrapper objects (or some
name like that) which point to the other fields that they have been
constrained to, and each row has an owner. So you should be able to
track through to find an object that has a reference to an owner, but
thinks that the owner should have an ID equal to its foreign key, and
that disagrees with what the owner thinks.


On 21 June 2013 06:45, Mariano Martinez Peck <[hidden email]> wrote:

>
>
>>
>>   One thing you might try is making an example where you force the IDs
>> of the asset identifications rather than letting them be generated.
>
>
> Ok I did this. I changed the mapping to use a normal platform int4 and I set
> the IDs by hand before saving them.
>
>>
>> If
>> you explicitly set them as a value, and then something else tries to
>> make it a different value, you'll get an exception. It might not be an
>> easy one to understand, but basically you should see a mapping trying
>> to set a value that's already set.
>
>
> This is what I am getting. Its 'Inconsistent values in field'. This is a
> DirectMapping for ID which is trying the set id.
> If I see the variables in #mapFromObject: anObject toTarget: target
> puttingRowsIn: aRowMap
> everything looks ok: target and anObject id are fine.
> The problem is the row that is answered by "aRowMap findOrAddRowForTable:
> self field table withKey: target."
> is a weird object... :
>
> a DatabaseRow(DP_ASSET_IDENTIFICATION)
>     Field(DP_ASSET_IDENTIFICATION.ID)->56
>     Field(DP_ASSET_IDENTIFICATION.ASSET_DESCRIPTION)->an Object
>     Field(DP_ASSET_IDENTIFICATION.ASSET_IDENTIFIER)->an Object
>     Field(DP_ASSET_IDENTIFICATION.CUSIP)->an Object
>     Field(DP_ASSET_IDENTIFICATION.ISIN)->an Object
>     Field(DP_ASSET_IDENTIFICATION.EXPIRATION_DATE)->an Object
>     Field(DP_ASSET_IDENTIFICATION.MULTIPLIER)->an Object
>     Field(DP_ASSET_IDENTIFICATION.IS_FOREIGN_SECURITY)->an Object
>     Field(DP_ASSET_IDENTIFICATION.ASSET_CLASS_NAME_ID)->an Object
>     Field(DP_ASSET_IDENTIFICATION.SECURITY_CLASS_NAME_ID)->an Object
>     Field(DP_ASSET_IDENTIFICATION.CIK_ENTITY_ID)->an Object
>
>
> There...that ID 56 is different to 'anObject' and 'target' id, which is 220.
>
>  mmmmmm
>
> and...remember that if I remove the all the mappings from
> DpAssetIdentification to DpSecurityTickerSymbolAssociation it works....
>
> I attach the PharoDebug.log just in case.
>
> Thanks in advance!
>
>> You can also set debugWrite: on a
>> mapping to get a debugger every time it writes, which might be
>> helpful, though again it can be tricky to understand. But possibly the
>> easist is to look for any other mappings that involve the ID of asset
>> identification or ASSET_IDENTIFICATION_ID.
>>
>> Alan
>>
>> On 19 June 2013 08:57, Mariano Martinez Peck <[hidden email]>
>> wrote:
>> > Hi,
>> >
>> > I am using Glorp with PostgreSQL in Pharo with the native client. All my
>> > classes/tables have an ID with a sequence. I have a bi-directional
>> > OneToMany
>> > relation and I have problems with the IDs generated from the sequences.
>> >
>> > The tables involved is DpAssetIdentification that has a OneToMany
>> > relation
>> > to DpSecurityTickerSymbolAssociation. Both have a secuence ID and I want
>> > the
>> > relation from both sides. The problem arises when I try to commit
>> > several
>> > DpAssetIdentification and somehow, the ID the object gets is a repeated
>> > (already existing ID). The problem seems very very similar to:
>> >
>> > https://groups.google.com/forum/?fromgroups#!msg/glorp-group/iZ6NlGfuiKg/PQ8Z3ikJC00J
>> > but the fix proposed at the end doesn't work for me.
>> >
>> > What is funny is that if I remove the all the OneToMany from
>> > DpAssetIdentification, it works...
>> >
>> > I paste the mappings just in case someone can help me.
>> > Thanks a lot in advance,
>> >
>> >
>> > classModelForDpAssetIdentification: aClassModel
>> > ...
>> > aClassModel newAttributeNamed: #securityTickerSymbolHistory
>> > collectionOf:
>> > DpSecurityTickerSymbolAssociation.
>> > ...
>> >
>> > ----
>> >
>> > descriptorForDpAssetIdentification: aDescriptor
>> > ...
>> > (aDescriptor newMapping: OneToManyMapping)
>> > attributeName: #securityTickerSymbolHistory;
>> > join: (Join
>> > from: (table fieldNamed: 'ID')
>> > to: ((self tableNamed: 'DP_SECURITY_TICKER_SYMBOL_ASSOCIATION')
>> > fieldNamed:
>> > 'ASSET_IDENTIFICATION_ID')).
>> > ...
>> >
>> > ----
>> >
>> > classModelForDpSecurityTickerSymbolAssociation: aClassModel
>> > ...
>> > aClassModel newAttributeNamed: #assetIdentification type:
>> > DpAssetIdentification.
>> > ...
>> >
>> > ---
>> >
>> > descriptorForDpSecurityTickerSymbolAssociation: aDescriptor
>> > ....
>> > (aDescriptor newMapping: OneToOneMapping)
>> > attributeName: #assetIdentification.
>> > ....
>> >
>> > ----
>> >
>> > tableForDP_SECURITY_TICKER_SYMBOL_ASSOCIATION: table
>> > | assetIdentificationID |
>> > (table createFieldNamed: 'ID' type: platform sequence) bePrimaryKey.
>> > assetIdentificationID := table createFieldNamed:
>> > 'ASSET_IDENTIFICATION_ID'
>> > type: platform int4.
>> > table addForeignKeyFrom: assetIdentificationID
>> > to: ((self tableNamed: 'DP_ASSET_IDENTIFICATION') fieldNamed: 'ID').
>> > ....
>> >
>> > ----
>> >
>> >
>> >
>> >
>> >
>> > --
>> > Mariano
>> > http://marianopeck.wordpress.com
>> >
>> > --
>> > 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 http://groups.google.com/group/glorp-group.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>>
>> --
>> 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 http://groups.google.com/group/glorp-group.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
> --
> 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 http://groups.google.com/group/glorp-group.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
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 http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.