Brandon Goodin wrote:

The removeFirstPrepend does not work in the way you are expecting. The
rFP works to remove the first prepend that is produced by tags nested
in the body of the tag using the rFP. Als, the <dyanmic> tag should
automatically remove the first prepend. So, in your case you should
remove the rFP from the isNotEmpty tags. It should then work in the
manner you expect. If it does not, then we may have an issue.

Brandon

On 2/17/06, Petr Kokorev <[EMAIL PROTECTED]> wrote:
Hello,


I have a simple insert query like this (I am sure that at least one of
the properties is not empty)

<insert id="insertItem" parameterClass="item">
 INSERT INTO ITEMS_TABLE
 (
 <dynamic>
   <isNotEmpty prepend="," property="propertyOne"
removeFirstPrepend="true">
     PROPERTY_ONE
   </isNotEmpty>
   <isNotEmpty prepend="," property="propertyTwo"
removeFirstPrepend="true">
     PROPERTY_TWO
   </isNotEmpty>
 </dynamic>
 ,
 VALUE
 )
 VALUES
 (
 <dynamic>
   <isNotEmpty prepend="," property="propertyOne"
removeFirstPrepend="true">
     #propertyOne#
   </isNotEmpty>
   <isNotEmpty prepend="," property="propertyTwo"
removeFirstPrepend="true">
     #propertyTwo#
   </isNotEmpty>
 </dynamic>
 ,
 #value:NUMERIC#
 )
</insert>

The generated String for the prepared statement will be like this in the
case of when both of the properties are not empty:

 INSERT INTO ITEMS_TABLE ( , PROPERTY_ONE , PROPERTY_TWO , VALUE )
VALUES ( , ? , ? , ? )

So the 1st prepend is not being removed.
I have done a workaround for it by specifying the prepend attribute for
the <dynamic> element:

 <dynamic prepend="(">

Then it worked fine:

 INSERT INTO ITEMS_TABLE ( PROPERTY_ONE , PROPERTY_TWO , VALUE ) VALUES
( ? , ? , ? )

I just wonder, is it normal?
Because I find the 'prepend="("' thing a bit ugly, and I would like to
have it like in my example.



Thanks in advance and respect

Pye

Hello again


I tried what you have recomended, I removed all the rFP attributes from <isNotEmpty> tags - the result was absolutely the same as the last time. If you do not specify the 'prepend="..."' attribute in <dynamic> tag, the first prepend is not removed.


Cheers

Pye

Reply via email to