ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Benedict <paul4chris...@yahoo.com>
Subject Re: interface property predicaments
Date Tue, 11 Jul 2006 04:33:51 GMT
One thing I forgot to mention: the "Article" class listed in my sqlmap is a typeAlias to the
actual implementation. Don't think I am trying to construct an interface :-)

Paul Benedict <paul4christ79@yahoo.com> wrote: I have two interfaces: Article and Person.
My problem is with my Article implementation:

public interface Article {
  public Person getPerson();
}

public class ArticleImpl extends Article {
  private Person person;
  public Person getPerson() {
    return person;
  }
  public void setPerson(Person person) {
    this.person = person;
  }
  // required for ibatis object construction
  public void setPerson(PersonImpl person) {
     this.person = person;
   }
 }

I am using ibatis to construct it as follows:

<resultMap id="articleMap" class="Article">
    <result property="person.id" column="person_id" />
</resultMap>

I get that annoying "cannot find WRITABLE property id in Person" message because it is looks
at Article.getPerson() which returns the interface not  implementation. But why should that
matter? This is wrong behavior, imo. I know ibatis constructs the inner object first. It will
create a PersonImpl, set property "id" from column "person_id", and then call the setter on
Article. 

Otherwise, I am left believing ibatis cannot work with classes which need to implement a read-only
interface..... or someone can recommend the solution, which I might be unable to find?

Paul
    

---------------------------------
How low will we go? Check out Yahoo! MessengerÂ’s low  PC-to-Phone call rates.

 		
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min
or less.
Mime
View raw message