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 12:56:24 GMT
Larry, I am implementing an API. So this is the problem I have to deal with :-(

The other guy is right. Ibatis thinks there is no setId on the Person because Person interface
is read-only, although in the sqlmap I am constructing a PersonImpl on an ArticleImpl. 

I believe ibatis can be changed to solve this problem: Assuming that ibatis constructs inner
objects as it navigates (does it?), it should use the instance it creates rather than looking
at the type from the getter.

Otherwise I will have to have a diferent getter on my object just for ibatis that returns
the impl.


Larry Meadors <lmeadors@apache.org> wrote: So...I do not understand..your beans are

How often do you swap out the implementation of your beans? ;-)


On 7/10/06, Paul Benedict 
> 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:
> 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.

Do you Yahoo!?
 Next-gen email? Have it all with the  all-new Yahoo! Mail Beta.
View raw message