[ 
https://issues.apache.org/jira/browse/IBATIS-390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12471145
 ] 

Paul Benedict commented on IBATIS-390:
--------------------------------------

I am glad someone brought this issue up. However, I believe there's a bigger 
(and more fun) issue here which is to not aggresively create inner objects 
which may already exist.

I sometimes have the design where I cannot construct the inner object directly 
in one call. All I can get is the primary key, and it is up to another DAO to 
finish building the inner object based on the key. The reason is because the 
business logic is so complex that it would a massive amount of SQL duplication 
to do an inner-join on ump-teen tables.

Based on this example, I have returned a Foo with an Bah inner object which has 
its primary key set. Then, the BahDAO would create the object fully and store 
it in Foo. The problem? The Bah object already exists and there is no need for 
iBATIS to create it if the reference already exists.

So I'd re-title this issue to be "Do not aggresively create inner objects" -- 
if a parent getter returns a non-null object, use that object -- otherwise 
create it and then call the setter.

> Property setter is required by Ibatis, even if only subproperties are being 
> modified
> ------------------------------------------------------------------------------------
>
>                 Key: IBATIS-390
>                 URL: https://issues.apache.org/jira/browse/IBATIS-390
>             Project: iBatis for Java
>          Issue Type: Bug
>          Components: SQL Maps
>    Affects Versions: 2.3.0
>         Environment: JDK 1.5
>            Reporter: Reuben Firmin
>
> From my post to the users mailing list:
> Let's say I have a class structure as per below. Ibatis does 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. I think Ibatis should behave like Spring in this regard.
> 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)
>     ...
> }
> ----------
> Larry sums up:
> 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?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to