Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 7149 invoked from network); 20 Sep 2005 15:36:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Sep 2005 15:36:57 -0000 Received: (qmail 19271 invoked by uid 500); 20 Sep 2005 15:36:55 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 19252 invoked by uid 500); 20 Sep 2005 15:36:55 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 19238 invoked by uid 99); 20 Sep 2005 15:36:54 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2005 08:36:54 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [194.25.134.80] (HELO mailout01.sul.t-online.com) (194.25.134.80) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2005 08:37:02 -0700 Received: from fwd19.aul.t-online.de by mailout01.sul.t-online.com with smtp id 1EHkAj-0003Sb-01; Tue, 20 Sep 2005 17:36:41 +0200 Received: from vrc840 (bptQJ2ZL8e22ixJp7AoqZ9dhTMzyt+cfuzWVOOaAHCyAAtgQEtFXrW@[84.177.209.169]) by fwd19.sul.t-online.de with esmtp id 1EHkAU-1JbftY0; Tue, 20 Sep 2005 17:36:26 +0200 From: "Volker_Reichel@t-online.de" To: , Subject: AW: Mapping Composition (aka composite property, aka value objects) Date: Tue, 20 Sep 2005 17:36:22 +0200 Message-ID: <002b01c5bdf9$0f013190$65f2fea9@vrc840> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.6604 (9.0.2911.0) In-Reply-To: <408a5c1d0509191311fc03c6f@mail.gmail.com> X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 Importance: Normal X-ID: bptQJ2ZL8e22ixJp7AoqZ9dhTMzyt+cfuzWVOOaAHCyAAtgQEtFXrW X-TOI-MSGID: 9dca04a0-32a6-4128-9a81-0d004712b7ca X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N If iBATIS is doing these steps Product product = new Product(); product.getPrice().setAmount(amount); the Product constructor has to create a Price instance as side-effect. My question is: What do you do in case the Product does not need to have a related Price instance for each Product? Volker -----Urspr�ngliche Nachricht----- Von: Dan Bradley [mailto:debradley@gmail.com] Gesendet: Montag, 19. September 2005 22:11 An: lmeadors@apache.org Cc: user-java@ibatis.apache.org Betreff: Re: Mapping Composition (aka composite property, aka value objects) Of course, after being stuck on it for a while, I figured it out right after I posted the question: It appears that the Product class must have a Price instance that is initialized, not null. In other words it looks like iBATIS doesn't do: Price price = new Price(); price.setAmount(amount); Product product = new Product(); product.setPrice(price); But instead does: Product product = new Product(); product.getPrice().setAmount(amount); Take this all with a grain of salt - I'm new to iBATIS! On 9/19/05, Larry Meadors wrote: > Can you explain more how the model is in Java, and in the database? > > Larry > > > On 9/19/05, Dan Bradley wrote: > > I have one entity, a Product, which holds a Price as a composed (not > > related) entity. A Price is a numeric value and a currency code as a > > String. Prices don't have a distinct identity in the database - they > > are value objects, so this is not the more usual persistent entity to > > persistent entity relationship mapping. > > > > How would you map this using iBATIS? I've tried a variety of things > > without success and can't yet find any documentation that covers this > > situation. Thanks. >