AW: [Fwd: RE: [OJB-developers] Mapping Question]
Brought to you by:
thma
From: Mahler T. <tho...@it...> - 2002-04-09 10:06:23
|
Hi Vikas, > > I hope this time I am posting my question on the right mailing list. > > Thomas, thank you so much for your reply to my original question on > Developer's mailing list. However, I am still not clear. I read > tutorial3.html and it does pretty good job of explaining inheritance > mapping. My situation has additional quirk of relation > mapping. Let me > try to explain.......... > > >From the classes point of view: there is class M with attributes as > follows: > > Class M > --------- > m_id integer > someValue String > child_type String > child_id integer > Does one M instance have a D attribute ? m_myD D ? > There is Class D and subclasses D1,D2,D3... (that need persistence) > > Class D > --------- > child_id integer > someData String > > class D1 > ---------- > child_id integer > aaValue String > bbValue String > > > Class D2 > ------------ > child_id integer > ccValue String > ddValue String > > Class D3 > ------------ > child_id integer > eeValue String > ffValue String > > The relation ship between M and instance of D (really D1 or > D2 or D3) is > determined by 'child_type' of class M. > > I understand inheritance mapping of class D and subclasses > D1,D2,D3. I > am leaning towards mapping each subclass with distinct table (with > FieldDescriptor for all attributes including inherited > attributes). How > do I map the relationship between M and D1,D2,D3 as they are > joined by > child_id to the appropriate table based on value of 'child_type'. > OJB supports polymorphism. That is you simply declare that M has a reference attribute of type D. To enable polymorph loading of D instances you must declare an extent for Class D that contains classes D1, D2, D3. This is also explained in Tutorial 3 (http://objectbridge.sourceforge.net/tutorial3.html#extents-and-polymorphism ). There is also plenty of sample code for similar problems in the test.ojb.broker package. The attribute child_type is not needed for OJB. HTH, Thomas > Does this make sense? > > Thanks for any help you can provide. > > Vikas > > > > > -----Original Message----- > From: Thomas Mahler [mailto:tho...@ho...] > Sent: Thursday, April 04, 2002 2:22 AM > To: Vikas Javiya > Cc: obj...@li... > Subject: Re: [OJB-developers] Mapping Question > > > Hi Vikas, > > please refer to the tutorial3.html. It explains how to build mappings > for inheritance hierarchies. > It also explains how mappings for 1:1, 1:n and m:n > associations are build. > > If you have further question that are not answered in the mentioned > document don't hesitate to post your questions to the > objectbridge-users > mailinglist. > > > HTH, > Thomas > > Vikas Javiya wrote: > > > Hello, > > > > > > > > A simple question regarding mapping; > > > > > > > > I have a class operation and a table OPERATION for > persistence. Two > > main attributes of operation are; resource_type and resource_id. > > Possible values for resource_type are 'Phone_number' , > 'Email_address', > > 'JMS_Queue', 'EJB_methods'. There is class 'resource' and > sub classes > > 'Phone_resource', > 'email_resource','JMS_resource','EJB_resource'. There > > are tables to map all of these sub classes of resource. > An OPERATION > > table is linked to any of these resource table via > resource_ID column > > depending on the resource_type column. In a way it is > dynamic mapping > > between 'operation' class and any of the resource classes > based on the > > value of resource_type. > > > > > > > > How do I map this in repository.xml?????????????? > > > > > > > > Thanks for your help. > > > > > > > > Vikas > > > > > > > > > > > > Vikas Javiya > > > > ThatOne Company > > > > 408.869.8112 (Phone) > > > > 408.487.9801 (Fax) > > > > www.ThatOne.com <http://www.thatone.com/> > > > > > -------------------------------------------------------------- > ---------- > > > > The information transmitted is intended only for the > person or entity to > > which it is addressed and may contain confidential and/or > privileged > > material. Any review, retransmission, dissemination or > other use of, or > > taking of any action in reliance upon, this information by > persons or > > entities other than the intended recipient is prohibited. If you > > received this in error, please contact the sender and delete the > > material from any computer. > > > > > -------------------------------------------------------------- > ---------- > > > > > > > > > > > > > > > > |