[vwnc] Glorp mapping problem

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

[vwnc] Glorp mapping problem

Maximiliano Taborda
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