Thanks Everybody.  Enabling namespaces in the sqlmapconfig fixed the select
attribute issue.  

However, now I am unable to load child objects using the complex property
feature.  I have turned on debugging for com.ibatis and I don't see a
statement for the child objects.  The relationship is that a PurchaseHeader
has many PurchaseDetail objects (the Java bean property is a Collection).
See the mapping below.  The only glitch I could imagine has to do with
order_no column, which is a char(10) and all of the rows in the table are
padded with spaces.  I tried trimming the select query, trimming the java
property, none of that made a difference.

    <resultMap class="PurchaseHeader" id="PurchaseHeader-result" >
        <result 
                property="orderNo" 
                javaType="java.lang.String"
                column="order_no" 
        />
        
        ...several subsequent 'result' tags...

        <!--  added complex property -->
        <result property="purchaseDetails"
                                column="order_no"
                                select="PurchaseDetail.getPurchaseDetail"
// also tried a local select...no dice.
                />
        </resultMap>

My Junit test is:

                PurchaseHeader header = new PurchaseHeader();
                header.setOrderNo( "3537729   " );
                PurchaseHeader result = null;
                try
                {
                        result =
(PurchaseHeader)client.queryForObject("PurchaseHeader.getPurchaseHeader",
header);
                        log.info("result orderNo = '" + result.getOrderNo()+
"'");
                }
                catch (SQLException e)
                {
                        log.error("failed to query \"getPurchaseHeader\"",
e);
                }
                assertTrue( header.equals(result) );
                assertNotNull( header.getPurchaseDetails() );  // Fails
                assertTrue( header.getPurchaseDetails().size() > 0);
                log.info("testDetailedRead:  SUCCEEDED!!!");



-----Original Message-----
From: Dan Bradley [mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ]

Sent: Thursday, October 13, 2005 3:06 PM
To: user-java@ibatis.apache.org
Subject: Re: Namespaces for Select Attribute

Just a sanity check - did you put useStatementNamespaces="true" in
your main config?

On 10/13/05, Voorhoeve, Niels {PBG} <[EMAIL PROTECTED]> wrote:
> Hey All,
>
> I was hoping that I would be able to use the namespace feature to refer to
a
> select in another file.  Apparently this is not doable.
> Would it be hard to implement?  Would it cause potential problems with
> circular dependencies (resultmap -> select -> resultmap)?
>
> Niels
>
> In PurchaseHeader.xml:
> <sqlMap namespace="PurchaseHeader">
>       etc...
>         <resultMap id="PurchaseHeaderAndDetails-result"
> class="PurchaseHeader" extends="PurchaseHeader-result">
>                 <result property="purchaseDetails"
>                                 column="order_no"
>                                 select="PurchaseDetail.getPurchaseDetail"
>                 />
>         </resultMap>
>         etc...
> </sqlMap>
>
> In PurchaseDetail.xml:
> <sqlMap namespace="PurchaseDetail">
> ...<select id="getPurchaseDetail" ...></select>
> </sqlMap
>

Reply via email to