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 Ch...@sybase.com on 2008/04/24 02:04:28 UTC

removeFirstPrepend

I'm having some trouble with the syntax of removeFirstPrepend. I have a 
procedure that I am attempting to invoke and all of the parameters are 
optional. SO I've embedded the content within the dynamic tag as 
documented and specified on each conditional element 
removeFirstPrepend="true", but the first content that is included does not 
get its prepend character "," removed and the SQL is invalid.

What am I missing?
Thanks...

  <procedure id="listCustomer" parameterClass="Customer" resultMap=
"CustomerResult"> 
    { call ${listCustomer_sp}
      <dynamic open="(" close=")">
        <isNotEmpty property="customerNumber" prepend="," 
removeFirstPrepend="true">
          @CustomerNumber = 
#customerNumber,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN#
        </isNotEmpty> 
        <isNotEmpty property="customerName" prepend="," removeFirstPrepend
="true">
          @CustomerName = 
#customerName,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN#
        </isNotEmpty> 
        <isNotEmpty property="customerClass" prepend="," 
removeFirstPrepend="true">
          @CustomerClass = 
#customerClass,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN#
        </isNotEmpty>
.....

 

Chris Mathrusse
christopher.mathrusse@sybase.com
Sybase, Inc
One Sybase Drive
Dublin, CA 94568
(925) 236-5553

Re: removeFirstPrepend

Posted by Ch...@sybase.com.
Thanks Brandon. That worked like a charm. I knew it was something with the 
syntax that I was just not understanding.

Chris...




"Brandon Goodin" <br...@gmail.com> 
04/23/2008 07:38 PM
Please respond to
user-java@ibatis.apache.org


To
user-java@ibatis.apache.org
cc

Subject
Re: removeFirstPrepend






Hey Chris,

removeFirstPrepend would not make sense where you have it specified. It 
would be specified on the dynamic tag. The idea being that the first child 
tag to generate a prepend would be silenced. However, the dynamic tag does 
this by default. You shouldn't need the removeFirstPrepend in this case. 
Try removing the open attribute on the dynamic tag with a prepend. In the 
end it should look like...


<procedure id="listCustomer" parameterClass="Customer" 
resultMap="CustomerResult">
  { call ${listCustomer_sp}
    <dynamic prepend="(" close=")">
      <isNotEmpty property="customerNumber" prepend=",">
        @CustomerNumber = 
#customerNumber,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN#
      </isNotEmpty> 
      <isNotEmpty property="customerName" prepend=",">
        @CustomerName = 
#customerName,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN#
      </isNotEmpty> 
      <isNotEmpty property="customerClass" prepend=",">
        @CustomerClass = 
#customerClass,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN#
      </isNotEmpty>
...

Let me know if that works,
Brandon Goodin

On Wed, Apr 23, 2008 at 7:04 PM, <Ch...@sybase.com> wrote:

I'm having some trouble with the syntax of removeFirstPrepend. I have a 
procedure that I am attempting to invoke and all of the parameters are 
optional. SO I've embedded the content within the dynamic tag as 
documented and specified on each conditional element 
removeFirstPrepend="true", but the first content that is included does not 
get its prepend character "," removed and the SQL is invalid. 

What am I missing? 
Thanks... 

  <procedure id="listCustomer" parameterClass="Customer" resultMap=
"CustomerResult"> 
    { call ${listCustomer_sp} 
      <dynamic open="(" close=")"> 
        <isNotEmpty property="customerNumber" prepend="," 
removeFirstPrepend="true"> 
          @CustomerNumber = 
#customerNumber,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN# 
        </isNotEmpty>               
        <isNotEmpty property="customerName" prepend="," removeFirstPrepend
="true"> 
          @CustomerName = 
#customerName,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN# 
        </isNotEmpty>   
        <isNotEmpty property="customerClass" prepend="," 
removeFirstPrepend="true"> 
          @CustomerClass = 
#customerClass,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN# 
        </isNotEmpty> 
..... 

  

Chris Mathrusse
christopher.mathrusse@sybase.com
Sybase, Inc
One Sybase Drive
Dublin, CA 94568
(925) 236-5553


Re: removeFirstPrepend

Posted by Brandon Goodin <br...@gmail.com>.
Hey Chris,

removeFirstPrepend would not make sense where you have it specified. It
would be specified on the dynamic tag. The idea being that the first child
tag to generate a prepend would be silenced. However, the dynamic tag does
this by default. You shouldn't need the removeFirstPrepend in this case. Try
removing the open attribute on the dynamic tag with a prepend. In the end it
should look like...


<procedure id="listCustomer" parameterClass="Customer"
resultMap="CustomerResult">
  { call ${listCustomer_sp}
    <dynamic prepend="(" close=")">
      <isNotEmpty property="customerNumber" prepend=",">
        @CustomerNumber =
#customerNumber,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN#
      </isNotEmpty>
      <isNotEmpty property="customerName" prepend=",">
        @CustomerName =
#customerName,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN#
      </isNotEmpty>
      <isNotEmpty property="customerClass" prepend=",">
        @CustomerClass =
#customerClass,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN#
      </isNotEmpty>
...

Let me know if that works,
Brandon Goodin

On Wed, Apr 23, 2008 at 7:04 PM, <Ch...@sybase.com> wrote:

>
> I'm having some trouble with the syntax of removeFirstPrepend. I have a
> procedure that I am attempting to invoke and all of the parameters are
> optional. SO I've embedded the content within the dynamic tag as documented
> and specified on each conditional element removeFirstPrepend="true", but the
> first content that is included does not get its prepend character ","
> removed and the SQL is invalid.
>
> What am I missing?
> Thanks...
>
>   <procedure id="listCustomer" parameterClass="Customer" resultMap=
> "CustomerResult">
>     { call ${listCustomer_sp}
>       <dynamic open="(" close=")">
>         <isNotEmpty property="customerNumber" prepend=","
> removeFirstPrepend="true">
>           @CustomerNumber =
> #customerNumber,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN#
>         </isNotEmpty>
>         <isNotEmpty property="customerName" prepend="," removeFirstPrepend
> ="true">
>           @CustomerName =
> #customerName,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN#
>         </isNotEmpty>
>         <isNotEmpty property="customerClass" prepend=","
> removeFirstPrepend="true">
>           @CustomerClass =
> #customerClass,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN#
>         </isNotEmpty>
> .....
>
>
>
> Chris Mathrusse
> christopher.mathrusse@sybase.com
> Sybase, Inc
> One Sybase Drive
> Dublin, CA 94568
> (925) 236-5553