Webvelocity/Glorp question (WV 1.0)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
jb
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Webvelocity/Glorp question (WV 1.0)

jb
Trying to create two foreign keys between two tables by something like
that:

tableForAaS: aTable
        | b1_id b2_id|
        (aTable createFieldNamed: 'id' type: platform serial) bePrimaryKey.
        b1_id := (aTable createFieldNamed: 'b1_id' type: platform integer) .
        b2_id := (aTable createFieldNamed: 'b2_id' type: platform integer) .
        aTable addForeignKeyFrom: b1_id to: ((self tableNamed: 'BbS')
fieldNamed: 'id').
        aTable addForeignKeyFrom: b2_id toTable: (self tableNamed: 'BbS')
tableForBbS: aTable
        (aTable createFieldNamed: 'id' type: platform serial) bePrimaryKey.
        (aTable createFieldNamed: 'nr' type: platform integer) beNullable:
false.

I get the error message:
Cannot calculate the join automatically, not enough information

There is no problem defiining only one foreign key, of course.

What can I do?

Joh.

--
You received this message because you are subscribed to the Google Groups "WebVelocity" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/webvelocity?hl=en.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Webvelocity/Glorp question (WV 1.0)

Alan Knight-3
The message means exactly what it says, but it's referring to the descriptor part, not the table part.

When you define a relationship from an Aa to a Bb, then normally you don't have to say much at all. Glorp will do its best to figure out the types, and based on the types, what foreign key relationships are involved. But if there's more than one foreign key from the Aa table to the Bb table, then it doesn't know which one to use. So you have to define the relationship more explicitly, so in

descriptorForAa: aDescriptor
      relationship1 := aDescriptor oneToOneMapping
           attributeName: #one;
        join: (Join from: b1_id to: ((self tableNamed: 'BbS')
fieldNamed: 'id')).

and similarly for relationship2. Actually, you might even get away with just doing it for one, and it might be smart enough to look for the potential foreign key that isn't already used. But I'm not sure about that.
          

At 03:02 AM 2010-09-07, joh wrote:
Trying to create two foreign keys between two tables by something like
that:

tableForAaS: aTable
        | b1_id b2_id|
        (aTable createFieldNamed: 'id' type: platform serial) bePrimaryKey.
        b1_id := (aTable createFieldNamed: 'b1_id' type: platform integer) .
        b2_id := (aTable createFieldNamed: 'b2_id' type: platform integer) .
        aTable addForeignKeyFrom: b1_id to: ((self tableNamed: 'BbS')
fieldNamed: 'id').
        aTable addForeignKeyFrom: b2_id toTable: (self tableNamed: 'BbS')
tableForBbS: aTable
        (aTable createFieldNamed: 'id' type: platform serial) bePrimaryKey.
        (aTable createFieldNamed: 'nr' type: platform integer) beNullable:
false.

I get the error message:
Cannot calculate the join automatically, not enough information

There is no problem defiining only one foreign key, of course.

What can I do?

Joh.

--
You received this message because you are subscribed to the Google Groups "WebVelocity" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/webvelocity?hl=en.

--
Alan Knight [|], Engineering Manager, Cincom Smalltalk

--
You received this message because you are subscribed to the Google Groups "WebVelocity" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/webvelocity?hl=en.
Loading...