You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Reuben Firmin <Re...@Copart.Com> on 2007/02/06 19:01:43 UTC
cannot write to property without a setter
Let's say I have a class structure as per below. Ibatis doesl not seem to let me address the path foo.bah.someProperty, because there is no setter (Foo#setBah). Specifically, I get "com.ibatis.common.beans.ProbeException: There is no WRITEABLE property". Spring, on the other hand, is fine with this particular setup, and in fact seems to ignore the setBah() method if it exists. Is there a good argument for one way or the other?
public class Foo
{
private Bah bah;
public Foo()
{
bah = new Bah();
}
public Bah getBah()
{
return bah;
}
}
public class Bah
{
private int someProperty;
public int getSomeProperty()
...
public void setSomeProperty(int someProperty)
...
}
Re: cannot write to property without a setter
Posted by Larry Meadors <lm...@apache.org>.
That is an interesting pattern - you can't change bah, but you can
change it's properties.
That *should* work, IMO. Can you add an issue in JIRA for that?
Larry
On 2/6/07, Reuben Firmin <Re...@copart.com> wrote:
> Let's say I have a class structure as per below. Ibatis doesl not seem to let me address the path foo.bah.someProperty, because there is no setter (Foo#setBah). Specifically, I get "com.ibatis.common.beans.ProbeException: There is no WRITEABLE property". Spring, on the other hand, is fine with this particular setup, and in fact seems to ignore the setBah() method if it exists. Is there a good argument for one way or the other?
>
> public class Foo
> {
> private Bah bah;
>
> public Foo()
> {
> bah = new Bah();
> }
>
> public Bah getBah()
> {
> return bah;
> }
> }
>
> public class Bah
> {
> private int someProperty;
>
> public int getSomeProperty()
> ...
>
> public void setSomeProperty(int someProperty)
> ...
> }
>
RE: cannot write to property without a setter
Posted by Daniel Pitts <Da...@cnet.com>.
Injection using blah.getFoo().setBar(bar); should be fine. There isn't
any setFoo, but its not a private injection.
________________________________
From: Nathan Maves [mailto:nathan.maves@gmail.com]
Sent: Tuesday, February 06, 2007 12:31 PM
To: user-java@ibatis.apache.org
Subject: Re: cannot write to property without a setter
I have never tried to do what you say in Spring.
In fact I have never tried it at all :)
My personal opinion is that you should never try and inject into private
properties. Follow the bean specs and all will be well.
Nathan
On 2/6/07, Reuben Firmin <Re...@copart.com> wrote:
Let's say I have a class structure as per below. Ibatis doesl
not seem to let me address the path foo.bah.someProperty, because there
is no setter (Foo#setBah). Specifically, I get
"com.ibatis.common.beans.ProbeException : There is no WRITEABLE
property". Spring, on the other hand, is fine with this particular
setup, and in fact seems to ignore the setBah() method if it exists. Is
there a good argument for one way or the other?
public class Foo
{
private Bah bah;
public Foo()
{
bah = new Bah();
}
public Bah getBah()
{
return bah;
}
}
public class Bah
{
private int someProperty;
public int getSomeProperty()
...
public void setSomeProperty(int someProperty)
...
}
Re: cannot write to property without a setter
Posted by Nathan Maves <na...@gmail.com>.
I have never tried to do what you say in Spring.
In fact I have never tried it at all :)
My personal opinion is that you should never try and inject into private
properties. Follow the bean specs and all will be well.
Nathan
On 2/6/07, Reuben Firmin <Re...@copart.com> wrote:
>
> Let's say I have a class structure as per below. Ibatis doesl not seem to
> let me address the path foo.bah.someProperty, because there is no setter
> (Foo#setBah). Specifically, I get "com.ibatis.common.beans.ProbeException:
> There is no WRITEABLE property". Spring, on the other hand, is fine with
> this particular setup, and in fact seems to ignore the setBah() method if it
> exists. Is there a good argument for one way or the other?
>
> public class Foo
> {
> private Bah bah;
>
> public Foo()
> {
> bah = new Bah();
> }
>
> public Bah getBah()
> {
> return bah;
> }
> }
>
> public class Bah
> {
> private int someProperty;
>
> public int getSomeProperty()
> ...
>
> public void setSomeProperty(int someProperty)
> ...
> }
>