ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Voorhoeve, Niels {PBG}" <niels.voorho...@pepsi.com>
Subject RE: Namespaces for Select Attribute
Date Thu, 13 Oct 2005 20:47:14 GMT
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" >
	...several subsequent 'result' tags...

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

My Junit test is:

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

-----Original Message-----
From: Dan Bradley [mailto:debradley@gmail.com <mailto:debradley@gmail.com> ]

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} <niels.voorhoeve@pepsi.com> wrote:
> Hey All,
> I was hoping that I would be able to use the namespace feature to refer to
> 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

View raw message