Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 73323 invoked from network); 29 Jun 2006 21:07:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 Jun 2006 21:07:46 -0000 Received: (qmail 44460 invoked by uid 500); 29 Jun 2006 21:07:42 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 44442 invoked by uid 500); 29 Jun 2006 21:07:42 -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 44431 invoked by uid 99); 29 Jun 2006 21:07:42 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Jun 2006 14:07:42 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of jeffgbutler@gmail.com designates 66.249.92.171 as permitted sender) Received: from [66.249.92.171] (HELO ug-out-1314.google.com) (66.249.92.171) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Jun 2006 14:07:39 -0700 Received: by ug-out-1314.google.com with SMTP id k3so53136ugf for ; Thu, 29 Jun 2006 14:07:17 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=mBrxVoXEQWJfcVvX2Eq0gqUM9v0MsZIH/VZbfsV2fudP5TLdsNJSfZpNTfsXhT4Jj2BiuqaCacb75Dgi5jr+z8tL6282O1bWu3nEyR3GCaOvDczocGCsxZgWbyuL1S8tQrwBS2BU9spFXlhe0VBmhRRCmkD/YNa6C/I5BFWURaY= Received: by 10.66.244.10 with SMTP id r10mr2376621ugh; Thu, 29 Jun 2006 14:07:17 -0700 (PDT) Received: by 10.66.238.18 with HTTP; Thu, 29 Jun 2006 14:07:16 -0700 (PDT) Message-ID: Date: Thu, 29 Jun 2006 16:07:16 -0500 From: "Jeff Butler" To: user-java@ibatis.apache.org Subject: Re: Working with composite objects and the syntax phoneNumbers[0].areaCode In-Reply-To: <5820E7E2A928DB46824297946AC2024A9A5E96@pandore.ircm.priv> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_11165_28595393.1151615236978" References: <5820E7E2A928DB46824297946AC2024A9A5E96@pandore.ircm.priv> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_11165_28595393.1151615236978 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline It's more complex than that... (and I think Rick is using a List. I wrote = a test case with a List and got the same error). When the SqlMap is parsed there is a lot of initialization performed. One of these initializations is that the type handlers for all properties are calculated. The iBATIS object probes can't see through the List (or array) - they don't understand the [3] syntax. It's probably possible to fix this (all things are possible given enough coding), but it didn't seem too simple to me, so I thought it would be easier to update the documentation to say "not supported" :) Clinton was pretty vehement about not supporting this, we should probably get his opinion about the difficulties involved - that's an area of the cod= e that I'm still a little murky about. It's different for the dynamic SQL tags - they are parsed differently and the type handlers aren't calculated until the statement is run (if I understand that correctly). They also have special code to deal with the [3] syntax. Jeff Butler On 6/29/06, Poitras Christian wrote: > > Jeff, is it possible that this problem has something to do with the use > of an array instead of a List? > > Rick, you could use a List instead to store the phone numbers. You can us= e > a FixedLengthList from Jakarta common collections package if you want a > fixed length of phone numbers. > http://jakarta.apache.org/commons/collections/ > Maybe this could correct the problem if you adapt your SQL to return a > List of phone numbers. > > Christian > > ------------------------------ > *From:* Jeff Butler [mailto:jeffgbutler@gmail.com] > *Sent:* Thursday, 29 June 2006 14:16 > > *To:* user-java@ibatis.apache.org > *Subject:* Re: Working with composite objects and the syntax > phoneNumbers[0].areaCode > > > I should have looked before I lept... > > I looked into this a little more and as Clinton said, this is not > supported. Making it supported is far from a trivial fix to iBATIS. I'l= l > update the documentation accordingly. > > Jeff Butler > > > > On 6/29/06, Rick wrote: > > > > Thank you for answering my questions. I am new to iBatis and so far > > really dig it. > > > > > > > > Comments below=85. > > > > > > > > I am willing to update the FAQ (WIKI) with my workaround. > > ------------------------------ > > > > *From:* Jeff Butler [mailto: jeffgbutler@gmail.com] > > *Sent:* Wednesday, June 28, 2006 8:13 PM > > > > *To:* user-java@ibatis.apache.org > > *Subject:* Re: Working with composite objects and the syntax > > phoneNumbers[0].areaCode > > > > > > > > This may be a bug in iBATIS. I'll take a closer look tomorrow. > > > > > > > > ** Somebody asked before and was told it is not a bug by Clinton see ht= tp://www.mail-archive.com/dev@ibatis.apache.org/msg00521.html > > . > > > > > > > > It's a little unusual to use this syntax in a result map - so maybe > > that's why it's not come up sooner (no excuses - it should work). > > > > > > > > ** It maybe unusual but according to the developer guide page 50 as of > > 6/16/2006 this should work. I think iBatis target market is mature data= base > > schemas (read legacy). > > > > A lot of mature schemas are highly un-normalized for speed. I was > > surprised that it did not work. > > > > > > > > *** I am not sure if it is a bug or a feature request. I think it needs > > to be fixed OR page 50 needs to be reworded a bit since it says this wi= ll > > work. :o) > > > > I have a work around so I am not stuck. > > > > > > > > It is common to use this type of syntax with the dynamic sql tags, I > > know for sure that it works in that circumstance. > > > > > > > > ** Good to know. I'll need to work with those as well. > > > > > > > > > > > > Jeff Butler > > > > > > > > On 6/28/06, *Rick* < ricks_mailinglists@arc-mind.com> wrote: > > > > I have a workaround as follows: > > > > > > > > (Notice I added setPhoneNumber1=85 and getPhoneNumber1=85. It works, bu= t not > > as clean as the old version. I don't want the object model tied this cl= ose > > to the db structure. ) > > > > > > > > package qcom.cas.mysourcej.poc.model; > > > > > > > > import java.io.Serializable; > > > > import java.util.ArrayList; > > > > import java.util.List; > > > > > > > > public class Contact implements Serializable { > > > > private List phoneNumbers =3D new ArrayList(); > > > > > > > > > > > > private String name; > > > > private boolean primaryContact; > > > > private String relationship =3D "Spouse"; > > > > > > > > public Contact() { > > > > phoneNumbers.add(new Phone()); > > > > phoneNumbers.add(new Phone()); > > > > phoneNumbers.add(new Phone()); > > > > phoneNumbers.add(new Phone()); > > > > } > > > > > > > > > > > > > > > > public Contact(String name) { > > > > super(); > > > > this.name =3D name; > > > > } > > > > > > > > public Contact(String name, Phone phone) { > > > > super(); > > > > this.name =3D name; > > > > phoneNumbers.add(phone); > > > > } > > > > > > > > public Contact(String name, Phone phone, String > > relationship) { > > > > this(name, phone); > > > > this.relationship =3D relationship; > > > > } > > > > > > > > public boolean isPrimaryContact() { > > > > return primaryContact; > > > > } > > > > public void setPrimaryContact(boolean primaryContact) { > > > > this.primaryContact =3D primaryContact; > > > > } > > > > public String getName() { > > > > return name; > > > > } > > > > public void setName(String name) { > > > > this.name =3D name; > > > > } > > > > public List getPhoneNumbers() { > > > > return phoneNumbers; > > > > } > > > > public void setPhoneNumbers(List phoneNumbers) { > > > > this.phoneNumbers =3D phoneNumbers; > > > > } > > > > > > > > public String getRelationship() { > > > > return relationship; > > > > } > > > > > > > > public void setRelationship(String relationship) { > > > > this.relationship =3D relationship; > > > > } > > > > > > > > public void setPhoneNumber1(Phone phone) { > > > > this.phoneNumbers.set(0, phone); > > > > } > > > > public void setPhoneNumber2(Phone phone) { > > > > this.phoneNumbers.set(1, phone); > > > > } > > > > public void setPhoneNumber3(Phone phone) { > > > > this.phoneNumbers.set(2, phone); > > > > } > > > > public void setPhoneNumber4(Phone phone) { > > > > this.phoneNumbers.set(3, phone); > > > > } > > > > > > > > public Phone getPhoneNumber1(){ > > > > return (Phone) this.phoneNumbers.get(0); > > > > } > > > > public Phone getPhoneNumber2(){ > > > > return (Phone) this.phoneNumbers.get(1); > > > > } > > > > public Phone getPhoneNumber3(){ > > > > return (Phone) this.phoneNumbers.get(2); > > > > } > > > > public Phone getPhoneNumber4(){ > > > > return (Phone) this.phoneNumbers.get(3); > > > > } > > > > > > > > } > > > > > > > > > > > > I am in no hurry for a solution, but I vote that you support the syntax > > you declare on page 50 of your user doc. (I don't really get a vote but= if I > > did that is how I would vote). > > > > > > > > Rick Hightower > > > > > > ------------------------------ > > > > *From:* Rick [mailto: ricks_mailinglists@arc-mind.com] > > *Sent:* Wednesday, June 28, 2006 5:22 PM > > *To:* user-java@ibatis.apache.org > > *Subject:* Working with composite objects and the syntax > > phoneNumbers[0].areaCode > > > > > > > > > > > > I have a result set that has phone1, phone2, phone3, phone4, areaCode1, > > areaCode2, areaCode3, areaCode4. > > > > > > > > I want to map these to composite objects. > > > > > > > > I.e., Employee has Contacts, Contact has phone numbers, phone number > > consist of number and area code. > > > > > > > > When I try to map this, I get this error: > > > > > > > > > > > > Caused by: > > > > com.ibatis.common.beans.ProbeException: There is no WRITEABLE property > > named 'phoneNumbers[0]' in class 'qcom.cas.mysourcej.poc.model.Contact = ' > > > > at com.ibatis.common.beans.ClassInfo.getSetterType( > > ClassInfo.java:174) > > > > at > > com.ibatis.common.beans.GenericProbe.getClassPropertyTypeForSetter( > > GenericProbe.java:250) > > > > at > > com.ibatis.common.beans.GenericProbe.getPropertyTypeForSetter( > > GenericProbe.java:137) > > > > at > > com.ibatis.sqlmap.engine.builder.xml.BaseParser.resolveTypeHandler( > > BaseParser.java:68) > > > > at > > com.ibatis.sqlmap.engine.builder.xml.SqlMapParser$15.process( > > SqlMapParser.java:403) > > > > =85 > > > > > > > > Here is my mapping file: > > > > > > > > > qcom.cas.mysourcej.poc.model.Employee" groupBy=3D "emplid" > > > > > > > > > > > > > > /> > > > > > > > > > > > > > qcom.cas.mysourcej.poc.model.Contact" > > > > > > > > > > > > > > typeHandler=3D " > > qcom.cas.commons.ibatis.typehandler.StringBooleanTypeHandler" /> > > > > > > > > > /> > > > > > /> > > > > > /> > > > > > /> > > > > > /> > > > > > /> > > > > > /> > > > > > /> > > > > > > > > > > > > Page 50 of the iBatis user manual states that the syntax > > phoneNumbers[3].areaCode is possible for a mapping. > > > > > > > > I googled this as follows: > > http://www.google.com/search?hl=3Den&lr=3Dlang_en&newwindow=3D1&rls=3DG= GLG%2CGGLG%3A2006-17%2CGGLG%3Aen&q=3D%22There+is+no+WRITEABLE+property+name= d%22+ProbeException > > > > > > > > I did notice that there was a similar issue at: > > http://www.mail-archive.com/dev@ibatis.apache.org/msg00521.html > > > > > > > > It seems this syntax may not be supported even though the documents > > elude that it is on page 50. How do you do this w/o the above syntax? > > > > > > > > Here is the object model for reference=85. > > > > > > > > package qcom.cas.mysourcej.poc.model; > > > > > > > > import java.io.Serializable; > > > > import java.util.ArrayList; > > > > import java.util.List; > > > > > > > > public class Contact implements Serializable { > > > > private List phoneNumbers =3D new ArrayList(); > > > > > > > > > > > > private String name; > > > > private boolean primaryContact; > > > > private String relationship =3D "Spouse"; > > > > > > > > public Contact() { > > > > phoneNumbers.add(new Phone()); > > > > phoneNumbers.add(new Phone()); > > > > phoneNumbers.add(new Phone()); > > > > phoneNumbers.add(new Phone()); > > > > } > > > > > > > > > > > > > > > > public Contact(String name) { > > > > super(); > > > > this.name =3D name; > > > > } > > > > > > > > public Contact(String name, Phone phone) { > > > > super(); > > > > this.name =3D name; > > > > phoneNumbers.add(phone); > > > > } > > > > > > > > public Contact(String name, Phone phone, String relationship) { > > > > this(name, phone); > > > > this.relationship =3D relationship; > > > > } > > > > > > > > public boolean isPrimaryContact() { > > > > return primaryContact; > > > > } > > > > public void setPrimaryContact(boolean primaryContact) { > > > > this.primaryContact =3D primaryContact; > > > > } > > > > public String getName() { > > > > return name; > > > > } > > > > public void setName(String name) { > > > > this.name =3D name; > > > > } > > > > public List getPhoneNumbers() { > > > > return phoneNumbers; > > > > } > > > > public void setPhoneNumbers(List phoneNumbers) { > > > > this.phoneNumbers =3D phoneNumbers; > > > > } > > > > > > > > > > > > > > > > public String getRelationship() { > > > > return relationship; > > > > } > > > > > > > > > > > > > > > > public void setRelationship(String relationship) { > > > > this.relationship =3D relationship; > > > > } > > > > } > > > > > > > > package qcom.cas.mysourcej.poc.model; > > > > > > > > import java.io.Serializable; > > > > import java.util.ArrayList; > > > > import java.util.List; > > > > > > > > public class Employee implements Serializable{ > > > > private String emplid; > > > > private List directReports =3D new ArrayList(); > > > > private List contacts =3D new ArrayList(); > > > > private Employee boss; > > > > private String name; > > > > > > > > public Employee () { > > > > > > > > } > > > > > > > > public Employee(Employee boss, String name) { > > > > super(); > > > > this.boss =3D boss; > > > > this.name =3D name; > > > > if (this.boss !=3Dnull) { > > > > boss.addEmployee(this); > > > > } > > > > } > > > > > > > > public Employee(Employee boss, String name, Contact contact) { > > > > this(boss, name); > > > > contacts.add(contact); > > > > } > > > > > > > > public void addEmployee(Employee employee) { > > > > employee.setBoss(this); > > > > this.directReports.add(employee); > > > > } > > > > public String getName() { > > > > return name; > > > > } > > > > public void setName(String name) { > > > > this.name =3D name; > > > > } > > > > public List getDirectReports() { > > > > return directReports; > > > > } > > > > public void setDirectReports(List directReports) { > > > > this.directReports =3D directReports; > > > > } > > > > public Employee getBoss() { > > > > return boss; > > > > } > > > > public void setBoss(Employee boss) { > > > > this.boss =3D boss; > > > > } > > > > public List getContacts() { > > > > return contacts; > > > > } > > > > public void setContacts(List contacts) { > > > > this.contacts =3D contacts; > > > > } > > > > > > > > public String toString() { > > > > return name; > > > > } > > > > > > > > public String getEmplid() { > > > > return emplid; > > > > } > > > > > > > > public void setEmplid(String emplid) { > > > > this.emplid =3D emplid; > > > > } > > > > } > > > > > > > > package qcom.cas.mysourcej.poc.model; > > > > > > > > import java.io.Serializable; > > > > > > > > public class Phone implements Serializable{ > > > > private String areaCode; > > > > private String number; > > > > private boolean uS=3Dtrue; > > > > > > > > public Phone () { > > > > > > > > } > > > > > > > > public Phone(String areaCode, String number, boolean us) { > > > > super(); > > > > this.areaCode =3D areaCode; > > > > this.number =3D number; > > > > uS =3D us; > > > > } > > > > > > > > public String getAreaCode() { > > > > return areaCode; > > > > } > > > > public void setAreaCode(String areaCode) { > > > > this.areaCode =3D areaCode; > > > > } > > > > public String getNumber() { > > > > return number; > > > > } > > > > public void setNumber(String number) { > > > > this.number =3D number; > > > > } > > > > public boolean isUS() { > > > > return uS; > > > > } > > > > public void setUS(boolean us) { > > > > uS =3D us; > > > > } > > > > > > > > public String toString() { > > > > if (uS) { > > > > return this.areaCode + "\\" + this.number; > > > > } else { > > > > return this.areaCode + "-" + this.number; > > > > } > > > > } > > > > } > > > > > > > > > > > > > > > > > > > > ------=_Part_11165_28595393.1151615236978 Content-Type: text/html; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
It's more complex than that... (and I think Rick is using a List. = ; I wrote a test case with a List and got the same error).
 
When the SqlMap is parsed there is a lot of initialization performed.&= nbsp; One of these initializations is that the type handlers for all proper= ties are calculated.  The iBATIS object probes can't see through the L= ist (or array) - they don't understand the [3] syntax.
 
It's probably possible to fix this (all things are possible given= enough coding), but it didn't seem too simple to me, so I thought it would= be easier to update the documentation to say "not supported" :)<= /div>
 
Clinton was pretty vehement about not supporting this, we should proba= bly get his opinion about the difficulties involved - that's an area of the= code that I'm still a little murky about.
 
It's different for the dynamic SQL tags - they are parsed differently = and the type handlers aren't calculated until the statement is run (if I un= derstand that correctly).  They also have special code to deal with th= e [3] syntax.
 
Jeff Butler


 
On 6/29/06, = Poitras Christian <C= hristian.Poitras@ircm.qc.ca> wrote:
Jeff, is it possible that this problem has something to do wit= h the use of an array instead of a List?
 
Rick, you could use a List instead to store the phone numbers.= You can use a FixedLengthList from Jakarta common collections package if y= ou want a fixed length of phone numbers.
Maybe this could correct the problem if you adapt your SQL to = return a List of phone numbers.
 
Christian


From: Jeff Butler [mailto:jeffgbutler@gmail.com]
Sent: Thursday, 29 June 2006 14:16

To: user-java@ibatis.apache.org
Subject: Re: Working with composite objects and the syntax phoneNumbers[0].area= Code

 
I should have looked before I lept...
 
I looked into this a little more and as Clinton said, this is not supp= orted.  Making it supported is far from a trivial fix to iBATIS.&= nbsp; I'll update the documentation accordingly.
 
Jeff Butler


 
On 6/29/06, = Rick <ricks_maili= nglists@arc-mind.com > wrote:=20

Thank you for answering my question= s. I am new to iBatis and so far really dig it.

 

Comments below=85.

 

I am willing to update the FAQ (WIK= I) with my workaround.


From: Jeff= Butler [mailto:=20 jeffgbutler@gmail.com]
= Sent: Wednesday, June 28, 2006= 8:13 PM=20

Subject: Re: Working w= ith composite objects and the syntax phoneNumbers[0].areaCode=20

 

** Somebody asked before and was to= ld it is not a bug by Clinton see = http://www.mail-archive.com/dev@ibatis.apache.org/msg00521.html=20 .=

 

 

** It maybe unusual but according t= o the developer guide page 50 as of 6/16/2006 this should work. I think iBa= tis target market is mature database schemas (read legacy).=20

A lot of mature schemas are highly = un-normalized for speed. I was surprised that it did not work.

 

*** I am not sure if it is a bug or= a feature request. I think it needs to be fixed OR page 50 needs to be rew= orded a bit since it says this will work. :o)=20

I have a work around so I am not st= uck.

 

** Good to know. I'll need to work = with those as well.

 

On 6/28/06, Rick &l= t; ricks_mailinglists@arc-mind.com> wrote:

I have a workaround as follows:

 

(Notice I added setPhoneNumber1=85 = and getPhoneNumber1=85. It works, but not as clean as the old version. I do= n't want the object model tied this close to the db structure. )=20

 

package qcom.cas.mysourcej.poc.mode= l;

 

import java.io.Serializable;=

import java.util.ArrayList;<= /font>

import java.util.List;

 

public class Contact implements Ser= ializable {

      = ;      private List phoneNumbers =3D new ArrayList= ();

 

 

      = ;      private String name;

      = ;      private boolean primaryContact;

      = ;      private String relationship =3D "Spous= e";

 

      = ;      public Contact() {

      = ;            &n= bsp;     phoneNumbers.add(new Phone());

      = ;            &n= bsp;     phoneNumbers.add(new Phone());

      = ;            &n= bsp;     phoneNumbers.add(new Phone());

      = ;            &n= bsp;     phoneNumbers.add(new Phone());

      = ;      }

 

 

 

      = ;      public Contact(String name) {=

      = ;            &n= bsp;     super();

      = ;            &n= bsp;     this.name =3D name;

      = ;      }

 

      = ;      public Contact(String name, Phone phone) {<= /span>

      = ;            &n= bsp;     super();

      = ;            &n= bsp;     this.name =3D name;

      = ;            &n= bsp;     phoneNumbers.add(phone);

      = ;      }

 

      = ;      public Contact(String name, Phone phone, St= ring relationship) {

      = ;            &n= bsp;     this(name, phone);

      = ;            &n= bsp;     this.relationship =3D relationship;

      = ;      }

 

      = ;      public boolean isPrimaryContact() {<= /font>

      = ;            &n= bsp;     return primaryContact;

      = ;      }

      = ;      public void setPrimaryContact(boolean prima= ryContact) {

      = ;            &n= bsp;     this.primaryContact =3D primaryContact;=

      = ;      }

      = ;      public String getName() {

      = ;            &n= bsp;     return name;

      = ;      }

      = ;      public void setName(String name) {

      = ;            &n= bsp;     this.name =3D name;

      = ;      }

      = ;      public List getPhoneNumbers() {

      = ;            &n= bsp;     return phoneNumbers;

      = ;      }

      = ;      public void setPhoneNumbers(List phoneNumbe= rs) {

      = ;            &n= bsp;     this.phoneNumbers =3D phoneNumbers;

      = ;      }

 

      = ;      public String getRelationship() {

      = ;            &n= bsp;     return relationship;

      = ;      }

 

      = ;      public void setRelationship(String relation= ship) {

      = ;            &n= bsp;     this.relationship =3D relationship;

      = ;      }

 

      = ;      public void setPhoneNumber1(Phone phone) {<= /span>

      = ;            &n= bsp;     this.phoneNumbers.set(0, phone);=

      = ;      }

      = ;      public void setPhoneNumber2(Phone phone) {<= /span>

      = ;            &n= bsp;     this.phoneNumbers.set(1, phone);=

      = ;      }

      = ;      public void setPhoneNumber3(Phone phone) {<= /span>

      = ;            &n= bsp;     this.phoneNumbers.set(2, phone);=

      = ;      }

      = ;      public void setPhoneNumber4(Phone phone) {<= /span>

      = ;            &n= bsp;     this.phoneNumbers.set(3, phone);=

      = ;      }

 

      = ;      public Phone getPhoneNumber1(){

      = ;            &n= bsp;     return (Phone) this.phoneNumbers.get(0);

      = ;      }

      = ;      public Phone getPhoneNumber2(){

      = ;            &n= bsp;     return (Phone) this.phoneNumbers.get(1);

      = ;      }

      = ;      public Phone getPhoneNumber3(){

      = ;            &n= bsp;     return (Phone) this.phoneNumbers.get(2);

      = ;      }

      = ;      public Phone getPhoneNumber4(){

      = ;            &n= bsp;     return (Phone) this.phoneNumbers.get(3);

      = ;      }

 

}

 

 

I am in no hurry for a solution, bu= t I vote that you support the syntax you declare on page 50 of your user do= c. (I don't really get a vote but if I did that is how I would vote).=20

 

Rick Hightower

 


From: Rick= [mailto:=20 ricks_mailinglists@arc-m= ind.com]
Sent: Wedn= esday, June 28, 2006 5:22 PM=20
To: user-java@ibatis.apache.org
Subject: Working with composite objects and the syntax phoneNumb= ers[0].areaCode

 

I have a result set that has phone1, phone2, phone3, phone4, ar= eaCode1, areaCode2, areaCode3, areaCode4.

 

I want to map these to composite objects.

 

I.e., Employee has Contacts, Contact has phone numbers, phone n= umber consist of number and area code.

 

When I try to map this, I get this error:

 

 

Caused by:

com.ibatis.common.beans.ProbeException: There is no WRITEABLE p= roperty named 'phoneNumbers[0]' in class 'qcom.cas.mysourcej.poc.model.Cont= act '

          &nb= sp; at com.ibatis.common.beans.ClassInfo.getSetterType(ClassInfo.java:174)<= /span>

          &nb= sp; at com.ibatis.common.beans.GenericProbe.getClassPropertyTypeForSetter(G= enericProbe.java:250)

          &nb= sp; at com.ibatis.common.beans.GenericProbe.getPropertyTypeForSetter(Generi= cProbe.java:137)

          &nb= sp; at com.ibatis.sqlmap.engine.builder.xml.BaseParser.resolveTypeHandler(B= aseParser.java:68)

          &nb= sp; at com.ibatis.sqlmap.engine.builder.xml.SqlMapParser$15.process(SqlMapP= arser.java:403)

          &nb= sp; =85

 

Here is my mapping file:

 

    &nbs= p; <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">resultMap= id=3D "employee" class =3D<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #2a00ff">"qco= m.cas.mysourcej.poc.model.Employee" groupBy<= /span>=3D<= font face=3D"Courier New" color=3D"#2a00ff" size=3D"2"> "emplid" >

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "emplid" column =3D<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #2a00ff">"emp= lid" />

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "name" column =3D<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #2a00ff">"nam= e" = />

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "contacts" resultMap =3D"employee.contacts " = />

    &nbs= p; </= resultMa= p >

 

    &nbs= p; <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">resultMap= id=3D "contacts" class =3D<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #2a00ff">"qco= m.cas.mysourcej.poc.model.Contact" >

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "name" column =3D<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #2a00ff">"con= tact_name" />

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "primaryContact" column =3D"primary_contact"=20

    =              &n= bsp;  typeHandler=3D "qcom.cas.commons.ibatis.typehandler.StringBooleanTypeHandler" <= /span>/><= font face=3D"Courier New" size=3D"2">

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "relationship" column =3D"relation"=20 />=

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "phoneNumbers[0].number" column =3D"phone1"=20 />=

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "phoneNumbers[1].number" column =3D"phone2"=20 />=

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "phoneNumbers[2].number" column =3D"phone3"=20 />=

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "phoneNumbers[3].number" column =3D"phone4"=20 />=

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "phoneNumbers[0].areaCode" column =3D"areaCode1"=20 />

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "phoneNumbers[1].areaCode" column =3D"areaCode2"=20 />

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "phoneNumbers[2].areaCode" column =3D"areaCode3"=20 />

    &nbs= p;       <<= span style=3D"FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f7f7f">result property=3D "phoneNumbers[3].areaCode" column =3D"areaCode4"=20 />

    &nbs= p; </= resultMa= p >

 

Page 50 of the iBatis user manual states that the syntax phoneNumbers[3].areaCode  is possible for a map= ping.

 

I googled this as follows: http://www.google.com/search?hl=3Den&lr=3Dlang_en&newwindow=3D1&= ;rls=3DGGLG%2CGGLG%3A2006-17%2CGGLG%3Aen&q=3D%22There+is+no+WRITEABLE+p= roperty+named%22+ProbeException

 

I did notice that there was a similar issue at: http://www.mail-archive.com/dev@ibatis.apache.org/msg00521.html<= /font>

 

It seems this syntax may not be supported even though the docum= ents elude that it is on page 50. How do you do this w/o the above syntax? =

 

Here is the object model for reference=85.

 

pa= ckage qcom.cas.mysourcej.poc.model;

 

im= port java.io.Serializable;

im= port java.util.ArrayList;

im= port java.util.List;

 

pu= blic class Contact implements Serializable {

&n= bsp;     private List phoneNumbers =3D new ArrayList();=

 

 

&n= bsp;     private String name;

&n= bsp;     private boolean primaryContact;<= /p>

&n= bsp;     private String relationship =3D "Spouse&q= uot;;

 

&n= bsp;     public Contact() {

&n= bsp;           phoneNumbe= rs.add(new Phone());

&n= bsp;           phoneNumbe= rs.add(new Phone());

&n= bsp;           phoneNumbe= rs.add(new Phone());

&n= bsp;           phoneNumbe= rs.add(new Phone());

&n= bsp;     }

 

 

 

&n= bsp;     public Contact(String name) {

&n= bsp;           super();

&n= bsp;           this.name =3D name;

&n= bsp;     }

 

&n= bsp;     public Contact(String name, Phone phone) {

&n= bsp;           super();

&n= bsp;           this.name =3D name;

&n= bsp;           phoneNumbe= rs.add(phone);

&n= bsp;     }

 

&n= bsp;     public Contact(String name, Phone phone, Strin= g relationship) {

&n= bsp;           this(name,= phone);

&n= bsp;           this.relat= ionship =3D relationship;

&n= bsp;     }

 

&n= bsp;     public boolean isPrimaryContact() {

&n= bsp;           return pri= maryContact;

&n= bsp;     }

&n= bsp;     public void setPrimaryContact(boolean primaryC= ontact) {

&n= bsp;           this.prima= ryContact =3D primaryContact;

&n= bsp;     }

&n= bsp;     public String getName() {

&n= bsp;           return nam= e;

&n= bsp;     }

&n= bsp;     public void setName(String name) {

&n= bsp;           this.name =3D name;

&n= bsp;     }

&n= bsp;     public List getPhoneNumbers() {<= /p>

&n= bsp;           return pho= neNumbers;

&n= bsp;     }

&n= bsp;     public void setPhoneNumbers(List phoneNumbers)= {

&n= bsp;           this.phone= Numbers =3D phoneNumbers;

&n= bsp;     }

 

 

 

&n= bsp;     public String getRelationship() {

&n= bsp;           return rel= ationship;

&n= bsp;     }

 

 

 

&n= bsp;     public void setRelationship(String relationshi= p) {

&n= bsp;           this.relat= ionship =3D relationship;

&n= bsp;     }

}<= /span>

 

pa= ckage qcom.cas.mysourcej.poc.model;

 

im= port java.io.Serializable;

im= port java.util.ArrayList;

im= port java.util.List;

 

pu= blic class Employee implements Serializable{

&n= bsp;     private String emplid;

&n= bsp;     private List directReports =3D new ArrayList()= ;

&n= bsp;     private List contacts =3D new ArrayList();

&n= bsp;     private Employee boss;

&n= bsp;     private String name;

 

&n= bsp;     public Employee () {

 

&n= bsp;     }

 

&n= bsp;     public Employee(Employee boss, String name) {<= /span>

&n= bsp;           super();

&n= bsp;           this.boss = =3D boss;

&n= bsp;           this.name =3D name;

&n= bsp;           if (this.b= oss !=3Dnull) {

&n= bsp;            = ;     boss.addEmployee(this);

&n= bsp;           }

&n= bsp;     }

 

&n= bsp;     public Employee(Employee boss, String name, Co= ntact contact) {

&n= bsp;           this(boss,= name);

&n= bsp;           contacts.a= dd(contact);

&n= bsp;     }

 

&n= bsp;     public void addEmployee(Employee employee) {

&n= bsp;           employee.s= etBoss(this);

&n= bsp;           this.direc= tReports.add(employee);

&n= bsp;     }

&n= bsp;     public String getName() {

&n= bsp;           return nam= e;

&n= bsp;     }

&n= bsp;     public void setName(String name) {

&n= bsp;           this.name =3D name;

&n= bsp;     }

&n= bsp;     public List getDirectReports() {=

&n= bsp;           return dir= ectReports;

&n= bsp;     }

&n= bsp;     public void setDirectReports(List directReport= s) {

&n= bsp;           this.direc= tReports =3D directReports;

&n= bsp;     }

&n= bsp;     public Employee getBoss() {

&n= bsp;           return bos= s;

&n= bsp;     }

&n= bsp;     public void setBoss(Employee boss) {

&n= bsp;           this.boss = =3D boss;

&n= bsp;     }

&n= bsp;     public List getContacts() {

&n= bsp;           return con= tacts;

&n= bsp;     }

&n= bsp;     public void setContacts(List contacts) {

&n= bsp;           this.conta= cts =3D contacts;

&n= bsp;     }

 

&n= bsp;     public String toString() {

&n= bsp;           return nam= e;

&n= bsp;     }

 

&n= bsp;     public String getEmplid() {

&n= bsp;           return emp= lid;

&n= bsp;     }

 

&n= bsp;     public void setEmplid(String emplid) {<= /font>

&n= bsp;           this.empli= d =3D emplid;

&n= bsp;     }

}<= /span>

 

pa= ckage qcom.cas.mysourcej.poc.model;

 

im= port java.io.Serializable;

 

pu= blic class Phone implements Serializable{

&n= bsp;     private String areaCode;

&n= bsp;     private String number;

&n= bsp;     private boolean uS=3Dtrue;

 

&n= bsp;     public Phone () {

 

&n= bsp;     }

 

&n= bsp;     public Phone(String areaCode, String number, b= oolean us) {

&n= bsp;           super();

&n= bsp;           this.areaC= ode =3D areaCode;

&n= bsp;           this.numbe= r =3D number;

&n= bsp;           uS =3D us;=

&n= bsp;     }

 

&n= bsp;     public String getAreaCode() {

&n= bsp;           return are= aCode;

&n= bsp;     }

&n= bsp;     public void setAreaCode(String areaCode) {

&n= bsp;           this.areaC= ode =3D areaCode;

&n= bsp;     }

&n= bsp;     public String getNumber() {

&n= bsp;           return num= ber;

&n= bsp;     }

&n= bsp;     public void setNumber(String number) {<= /font>

&n= bsp;           this.numbe= r =3D number;

&n= bsp;     }

&n= bsp;     public boolean isUS() {

&n= bsp;           return uS;=

&n= bsp;     }

&n= bsp;     public void setUS(boolean us) {<= /p>

&n= bsp;           uS =3D us;=

&n= bsp;     }

 

&n= bsp;     public String toString() {

&n= bsp;           if (uS) {<= /span>

&n= bsp;            = ;     return this.areaCode + "\\"  + thi= s.number;

&n= bsp;           } else {

&n= bsp;            = ;     return this.areaCode + "-"  + this= .number;

&n= bsp;           }

&n= bsp;     }

}<= /span>