Re: [vwnc] Glorp mapping problem

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

Re: [vwnc] Glorp mapping problem

Frank Urbach
Hallo Maximiliano,
 
I'm a little bit confused by naming ObjectA and ObjectB. In normal mapping ways you map a class to the database.
If I understand it correctly the mapping you need is a conditional mapping. There you can decide how in the given context you store the instances of a class.
In your definition given below I can't see the definition of the table for classA or classB. This would help to understand what you want.
 
HTH
 
Frank
 
 
 
Original Message     
   processed by David.InfoCenter 
Subject: 
[vwnc] Glorp mapping problem (11-Dez-2008 17:27)
From:    
To:      
 
Hello.

I'm trying to map an instance variable of a class to two differents objects, each one with its own table.
For example, if I have these objects:

     ObjectA
          instanceVariableNames: 'name others'

     ObjectB
          instanceVariableNames: 'name'

In ObjectA the variable others is a collection of ObjectA or ObjectB.
¿Wich is the correct way to map the #others variable in the ObjectA descriptor?

This is the code for the class models, the descriptors and the tables for the example:
classModelForObjectA: aClassModel
aClassModel addAttribute: #name.
aClassModel addAttribute: #others collectionOf: ? --> Wich is the type of this collection?

classModelForObjectB: aClassModel
aClassModel addAttribute: #name.

descriptorForObjectA: aDescriptor
(aDescriptor new: DirectMapping) from: #name to: (table fieldNamed: 'name').
--> How is the mapping definition for #others?

descriptorForObjectB: aDescriptor
(aDescriptor new: DirectMapping) from: #name to: (table fieldNamed: 'name').

tableForOBJECTS_A: aTable
aTable createFieldNamed: 'name' type: (self platform varChar: 12).

tableForOBJECTS_B: aTable
aTable createFieldNamed: 'name' type: (self platform varChar: 12).

tableForOBJECTS_LINK: aTable
aTable createFieldNamed: 'parent' type: (self platform varChar: 12). --> The parent is always an ObjectA
aTable createFieldNamed: 'child' type: (self platform varChar: 12). --> The child could be an ObjectA or an ObjectB

Could anybody help me with this? Is there another way to make a variable that is a collection that could store two or more kind of objects?

Thanks a lot.
Maximiliano

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

Edelstahlwerke Schmees GmbH 

Geschäftsleitung Clemens Schmees

Sitz D-01796 Pirna

Handelsregister Dresden HRB 54

E-Mail: [hidden email]

WEB:     www.schmees.com

 

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

 

This e-mail may contain confidental and/or privileged information. If you are not intended recipient or have received this e-mail in error, please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Glorp mapping problem

Maximiliano Taborda
Hi Frank. Thanks for your answer. I'm try to explain the problem more clear...

The ClassB is simple, I don't have any problme with this. But, the ClassA is like a composite. It has an instance variable wich is a collection. This collection could store instances of ClassA or instances of ClassB. Two classes are polymorphic.

So, the class definition for ClassA and ClassB are:

Smalltalk defineClass: #ClassA
     superclass: #{Core.Object}
     instanceVariableNames: 'id name description collection'

Smalltalk defineClass: #ClassB
     superclass: #{Core.Object}
     instanceVariableNames: 'id name description'

When I write the #classModelForClassA: method I need to specify the type of the objects stored in the collection, but this collection store two kind of objects (instances of ClassA or instances of ClassB)..

The code:
classModelForClassA: aModel
     aModel addAttribute: #id.
     aModel addAttribute: #name.
     aModel addAttribute: #description.
     aModel addAttribute: #collection collectionOf: ??. ##(I don't know wich is the type)

The table for the ClassA look like these:

#tableForCLASS_A: aTable
     (aTable createFieldNamed: 'id' type: self platform sequence) bePrimaryKey.
     aTable createFieldNamed: 'name' type: (self platform varChar: 12).
     aTable createFieldNamed: 'description' type: (self platform varChar: 256).

The table for the ClassB is equal to the previous.

#tableForCLASS_B: aTable
     (aTable createFieldNamed: 'id' type: self platform sequence) bePrimaryKey.
     aTable createFieldNamed: 'name' type: (self platform varChar: 12).
     aTable createFieldNamed: 'description' type: (self platform varChar: 256).

These two tables are related by a link table.

Now, the descriptor:

descriptorForClassA: aDescriptor
     (aDescriptor newMapping: DirectMapping) from: #id to: (classATable fieldNamed: 'id').
     (aDescriptor newMapping: DirectMapping) from: #name to: (classATable fieldNamed: 'name').
     (aDescriptor newMapping: DirectMapping) from: #description to: (classATable fieldNamed: 'description').
     ## In this line goes the map for #collection attribute, but I don't know how to write it. I took a look on the tests for ConditionalToManyMapping but not one of those cover the problem when you have a collection of this characteristics... or I miss something in the way.

Thanks for your time. I hope the problem is clear now.

Regards.
Maximiliano

2008/12/12 Frank Urbach <[hidden email]>
Hallo Maximiliano,
 
I'm a little bit confused by naming ObjectA and ObjectB. In normal mapping ways you map a class to the database.
If I understand it correctly the mapping you need is a conditional mapping. There you can decide how in the given context you store the instances of a class.
In your definition given below I can't see the definition of the table for classA or classB. This would help to understand what you want.
 
HTH
 
Frank
 
 
 
Original Message     
   processed by David.InfoCenter 
Subject: 
[vwnc] Glorp mapping problem (11-Dez-2008 17:27)
From:    
To:      
 
Hello.

I'm trying to map an instance variable of a class to two differents objects, each one with its own table.
For example, if I have these objects:

     ObjectA
          instanceVariableNames: 'name others'

     ObjectB
          instanceVariableNames: 'name'

In ObjectA the variable others is a collection of ObjectA or ObjectB.
¿Wich is the correct way to map the #others variable in the ObjectA descriptor?

This is the code for the class models, the descriptors and the tables for the example:
classModelForObjectA: aClassModel
aClassModel addAttribute: #name.
aClassModel addAttribute: #others collectionOf: ? --> Wich is the type of this collection?

classModelForObjectB: aClassModel
aClassModel addAttribute: #name.

descriptorForObjectA: aDescriptor
(aDescriptor new: DirectMapping) from: #name to: (table fieldNamed: 'name').
--> How is the mapping definition for #others?

descriptorForObjectB: aDescriptor
(aDescriptor new: DirectMapping) from: #name to: (table fieldNamed: 'name').

tableForOBJECTS_A: aTable
aTable createFieldNamed: 'name' type: (self platform varChar: 12).

tableForOBJECTS_B: aTable
aTable createFieldNamed: 'name' type: (self platform varChar: 12).

tableForOBJECTS_LINK: aTable
aTable createFieldNamed: 'parent' type: (self platform varChar: 12). --> The parent is always an ObjectA
aTable createFieldNamed: 'child' type: (self platform varChar: 12). --> The child could be an ObjectA or an ObjectB

Could anybody help me with this? Is there another way to make a variable that is a collection that could store two or more kind of objects?

Thanks a lot.
Maximiliano

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

Edelstahlwerke Schmees GmbH 

Geschäftsleitung Clemens Schmees

Sitz D-01796 Pirna

Handelsregister Dresden HRB 54

E-Mail: [hidden email]

WEB:     www.schmees.com

 

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

 

This e-mail may contain confidental and/or privileged information. If you are not intended recipient or have received this e-mail in error, please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Glorp mapping problem

Wallen, David

Hi Maximiliano,

 

I think you might also want to have a look at Roger Whitney’s tutorial, if you haven’t seen it already. There is a section called “Inheritance and polymorphic queries” which seems related to your description.

 

_________________________
Dave Wallen                      e-mail:  [hidden email]
Development                      phone:  415-731-2570 or (408)216-4580
Cincom Systems, Inc.                fax:  408-216-4501

http://www.cincom.com/visualworks

______________________________________________________________________


From: [hidden email] [mailto:[hidden email]] On Behalf Of Maximiliano Taborda
Sent: Friday, December 12, 2008 6:19 AM
To: Frank Urbach
Cc: [hidden email]
Subject: Re: [vwnc] Glorp mapping problem

 

Hi Frank. Thanks for your answer. I'm try to explain the problem more clear...

 

The ClassB is simple, I don't have any problme with this. But, the ClassA is like a composite. It has an instance variable wich is a collection. This collection could store instances of ClassA or instances of ClassB. Two classes are polymorphic.

 

So, the class definition for ClassA and ClassB are:

 

Smalltalk defineClass: #ClassA

     superclass: #{Core.Object}

     instanceVariableNames: 'id name description collection'

 

Smalltalk defineClass: #ClassB

     superclass: #{Core.Object}

     instanceVariableNames: 'id name description'

 

When I write the #classModelForClassA: method I need to specify the type of the objects stored in the collection, but this collection store two kind of objects (instances of ClassA or instances of ClassB)..

 

The code:

classModelForClassA: aModel

     aModel addAttribute: #id.

     aModel addAttribute: #name.

     aModel addAttribute: #description.

     aModel addAttribute: #collection collectionOf: ??. ##(I don't know wich is the type)

 

The table for the ClassA look like these:

 

#tableForCLASS_A: aTable

     (aTable createFieldNamed: 'id' type: self platform sequence) bePrimaryKey.

     aTable createFieldNamed: 'name' type: (self platform varChar: 12).

     aTable createFieldNamed: 'description' type: (self platform varChar: 256).

 

The table for the ClassB is equal to the previous.

 

#tableForCLASS_B: aTable

     (aTable createFieldNamed: 'id' type: self platform sequence) bePrimaryKey.

     aTable createFieldNamed: 'name' type: (self platform varChar: 12).

     aTable createFieldNamed: 'description' type: (self platform varChar: 256).

 

These two tables are related by a link table.

 

Now, the descriptor:

 

descriptorForClassA: aDescriptor

     (aDescriptor newMapping: DirectMapping) from: #id to: (classATable fieldNamed: 'id').

     (aDescriptor newMapping: DirectMapping) from: #name to: (classATable fieldNamed: 'name').

     (aDescriptor newMapping: DirectMapping) from: #description to: (classATable fieldNamed: 'description').

     ## In this line goes the map for #collection attribute, but I don't know how to write it. I took a look on the tests for ConditionalToManyMapping but not one of those cover the problem when you have a collection of this characteristics... or I miss something in the way.

 

Thanks for your time. I hope the problem is clear now.

 

Regards.

Maximiliano

 

2008/12/12 Frank Urbach <[hidden email]>

Hallo Maximiliano,

 

I'm a little bit confused by naming ObjectA and ObjectB. In normal mapping ways you map a class to the database.

If I understand it correctly the mapping you need is a conditional mapping. There you can decide how in the given context you store the instances of a class.

In your definition given below I can't see the definition of the table for classA or classB. This would help to understand what you want.

 

HTH

 

Frank

 

 

 

Original Message     

   processed by David.InfoCenter 

 

Subject: 

[vwnc] Glorp mapping problem (11-Dez-2008 17:27)

From:    

To:      

 

Hello.

 

I'm trying to map an instance variable of a class to two differents objects, each one with its own table.

For example, if I have these objects:

 

     ObjectA

          instanceVariableNames: 'name others'

 

     ObjectB

          instanceVariableNames: 'name'

 

In ObjectA the variable others is a collection of ObjectA or ObjectB.

¿Wich is the correct way to map the #others variable in the ObjectA descriptor?

 

This is the code for the class models, the descriptors and the tables for the example:

classModelForObjectA: aClassModel

aClassModel addAttribute: #name.

aClassModel addAttribute: #others collectionOf: ? --> Wich is the type of this collection?

 

classModelForObjectB: aClassModel

aClassModel addAttribute: #name.

 

descriptorForObjectA: aDescriptor

(aDescriptor new: DirectMapping) from: #name to: (table fieldNamed: 'name').

--> How is the mapping definition for #others?

 

descriptorForObjectB: aDescriptor

(aDescriptor new: DirectMapping) from: #name to: (table fieldNamed: 'name').

 

tableForOBJECTS_A: aTable

aTable createFieldNamed: 'name' type: (self platform varChar: 12).

 

tableForOBJECTS_B: aTable

aTable createFieldNamed: 'name' type: (self platform varChar: 12).

 

tableForOBJECTS_LINK: aTable

aTable createFieldNamed: 'parent' type: (self platform varChar: 12). --> The parent is always an ObjectA

aTable createFieldNamed: 'child' type: (self platform varChar: 12). --> The child could be an ObjectA or an ObjectB

 

Could anybody help me with this? Is there another way to make a variable that is a collection that could store two or more kind of objects?

 

Thanks a lot.

Maximiliano


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

 

Edelstahlwerke Schmees GmbH 

Geschäftsleitung Clemens Schmees

Sitz D-01796 Pirna

Handelsregister Dresden HRB 54

E-Mail: [hidden email]

WEB:     www.schmees.com

 

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

 

This e-mail may contain confidental and/or privileged information. If you are not intended recipient or have received this e-mail in error, please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Glorp mapping problem

Cesar Rabak
Wallen, David escreveu:

> Hi Maximiliano,
>
>  
>
> I think you might also want to have a look at Roger Whitney’s tutorial,
> if you haven’t seen it already. There is a section called “Inheritance
> and polymorphic queries” which seems related to your description.
>
>  
>
> http://www.eli.sdsu.edu/SmalltalkDocs/GlorpTutorial.pdf
>
>  
>
Dave,

I also thought something about the line Glorp Tutorial mentions, but the
implementation by Maximiliano (be it by design or some other constraint)
does not have a parent class (even if abstract) to use the mechanism
shown in the page 54 of the tutorial.

In fact, if Maximiliano can implement a parent class for his ClassA and
ClassB from the POV of OOA/OOD he's done!

I'm not knowledgeable enough on the intricacies of Glorp to say that's
the solution, though.

--
Cesar Rabak
GNU/Linux User 52247.
Get counted: http://counter.li.org/
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Glorp mapping problem

Claus Kick
In reply to this post by Wallen, David
Wallen, David wrote:

*snip*
> http://www.eli.sdsu.edu/SmalltalkDocs/GlorpTutorial.pdf

Can stuff like that be filed away somewhere under

smalltalk.cincom.com/documentation/

glorp/

i.e. GlorpTutorial_Whitney.pdf

?

By now, I am despairing of  the way Smalltalk documentation is either
not existent or hidden in secret treasure caves guarded by hungry red
dragons.

Caves whose locations you can only find out about after drinking with an
aged-adventurer in a shabby inn where he only hangs out on odd evenings
during the summer months.

Sorry, for the fantasy wrapping but the image just crossed my mind.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Glorp mapping problem

Alan Knight-2
While having the documentation better organized would be nice, I should point out that a google search for "Glorp Tutorial" turns this up as the third entry, and that it's specifically mentioned on the first entry, and that the first entry is also the first thing you find if you search for "Glorp Documentation". All hungry dragons should be so well indexed :-)

I also did respond to the original query in the glorp list, where I had a couple of suggestions, probably the best one was to have two different instance variables, one for each type, and then have API that combines them in-memory.

At 03:39 PM 12/15/2008, Claus Kick wrote:
Wallen, David wrote:

*snip*
> http://www.eli.sdsu.edu/SmalltalkDocs/GlorpTutorial.pdf

Can stuff like that be filed away somewhere under

smalltalk.cincom.com/documentation/

glorp/

i.e. GlorpTutorial_Whitney.pdf

?

By now, I am despairing of  the way Smalltalk documentation is either
not existent or hidden in secret treasure caves guarded by hungry red
dragons.

Caves whose locations you can only find out about after drinking with an
aged-adventurer in a shabby inn where he only hangs out on odd evenings
during the summer months.

Sorry, for the fantasy wrapping but the image just crossed my mind.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

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

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Glorp mapping problem

Maximiliano Taborda
Thanks to all for your answers.
At this moment, I get the Alan suggestion: have two instance variables.

Regards.
Maximiliano


2008/12/15 Alan Knight <[hidden email]>
While having the documentation better organized would be nice, I should point out that a google search for "Glorp Tutorial" turns this up as the third entry, and that it's specifically mentioned on the first entry, and that the first entry is also the first thing you find if you search for "Glorp Documentation". All hungry dragons should be so well indexed :-)

I also did respond to the original query in the glorp list, where I had a couple of suggestions, probably the best one was to have two different instance variables, one for each type, and then have API that combines them in-memory.


At 03:39 PM 12/15/2008, Claus Kick wrote:
Wallen, David wrote:

*snip*
> http://www.eli.sdsu.edu/SmalltalkDocs/GlorpTutorial.pdf

Can stuff like that be filed away somewhere under

smalltalk.cincom.com/documentation/

glorp/

i.e. GlorpTutorial_Whitney.pdf

?

By now, I am despairing of  the way Smalltalk documentation is either
not existent or hidden in secret treasure caves guarded by hungry red
dragons.

Caves whose locations you can only find out about after drinking with an
aged-adventurer in a shabby inn where he only hangs out on odd evenings
during the summer months.

Sorry, for the fantasy wrapping but the image just crossed my mind.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

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

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc