Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 32861 invoked from network); 21 Jun 2004 13:42:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 21 Jun 2004 13:42:20 -0000 Received: (qmail 96495 invoked by uid 500); 21 Jun 2004 13:42:15 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 96430 invoked by uid 500); 21 Jun 2004 13:42:14 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 96389 invoked by uid 99); 21 Jun 2004 13:42:14 -0000 Received: from [66.145.203.12] (HELO MAIL.osn.state.oh.us) (66.145.203.12) by apache.org (qpsmtpd/0.27.1) with ESMTP; Mon, 21 Jun 2004 06:42:14 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: How do you map a reference to an interface-backed class? (non-trivial) Date: Mon, 21 Jun 2004 09:42:04 -0400 Message-ID: <316E5B943771D311BAC500805FD7A07803431FE3@MAIL.osn.state.oh.us> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: How do you map a reference to an interface-backed class? (non-trivial) Thread-Index: AcRW0O6j4hvoMXnTRUyGZSnVxqDS/QAw1NzA From: "Clute, Andrew" To: "OJB Users List" , "OJB Developers List" X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N That's what I assumed, and was afraid of. I think I can get around it temporarily by actually creating a composite field that contains the classname and the PK in the same field (i.e. "foo.bar.CatalogItem:12345"), and then creating a custom Conversion that will take that string and instantiate the object. Now, is there any technical reason why there isn't a strategy to map a class that has a reference to an interface-backed class where the concrete classes are not mapped in the same table? It would seem to me, that such a feature could be implemented pretty straight-forward in the current architecture (and I would be willing to take that on), but I want to make sure I understand all of the ramifications of why this isn't done at this time (feature never implemented?, won't work with what we currently have?, etc. One staight-forward approach would to modify the repostiroy_user.xml definitions to allow the following type of mapping: -Andrew -----Original Message----- From: Thomas Dudziak [mailto:tomdz@first.fhg.de]=20 Sent: Sunday, June 20, 2004 10:17 AM To: OJB Users List Subject: Re: How do you map a reference to an interface-backed class? (non-trivial) > To give some more concrete to the example, here is what I have...I=20 > have two different objects that already exist: Course and CatalogItem. > Now at this point we need to start accepting payment for them, so I=20 > have created an Order and OrderItem, and I want the OrderItem to be=20 > able to contain either one of the objects. So I created a Sellable=20 > interface, and Course and CatalogItem now implement them. So, I now=20 > need to figure out how to map OrderItem so that when it is restored,=20 > the right object (Course or CatalogItem) is created. This will work if both Course and CatalogItem map to the same table. If you require them to be in different tables, then you'll probably have to do the loading manually. This means that you have the basic parts (primary key, ojbConcreteClass) in the same table, and load the other fields/references/collections on your own in the constructor of the concrete subclass. This is a bit more involved though. Tom --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org For additional commands, e-mail: ojb-user-help@db.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org