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 roberto <ro...@theaegis.org> on 2004/12/30 17:49:00 UTC

RE: sql fragment as parameter

What is ld.language?  Is that in the 'pojos' table with the dot notation?

 

Roberto

 

 

-----Original Message-----
From: Kris Barnhoorn [mailto:kris@biassweb.be] 
Sent: Thursday, December 30, 2004 11:54 AM
To: ibatis-user-java@incubator.apache.org
Subject: sql fragment as parameter

 

Hi,

 

First I'd like to thank the developers for this great tool.

 

I'd like to insert an sql fragment as a parameter to an sql select
statement.

what i do is generate some sql in a class which is used as parameterClass in
the xml file

 

the whereCriteriaString constructs the string based criteria selectable on
the webpage. Users can choose the make more than one "filter"

 

filter:  property | value | (AND | OR)

add filter

 

 

So I simply did this:

 

      <select id="getPojos" parameterClass="org.foo.SqlQuery"

            resultClass="org.foo.Pojo">

            SELECT *

            FROM `pojos` 

            WHERE 

            <dynamic>

                  <isNotEmpty property="whereCriteriaString">

                        #whereCriteriaString#

                  </isNotEmpty>

            </dynamic>

      </select>

 

What generates 

218 [main] DEBUG sql.PreparedStatement  - {pstm-100004} PreparedStatement:
SELECT * FROM `pojos` WHERE ? 

218 [main] DEBUG sql.PreparedStatement  - {pstm-100004} PreparedStatement:
Parameters: [(ld.language  =  'en' ) ]

218 [main] DEBUG sql.PreparedStatement  - {pstm-100004} Types:
[java.lang.String]

 

This doesn't work

 

So my question is can iBatis generate this?

 

218 [main] DEBUG sql.PreparedStatement  - {pstm-100004} PreparedStatement:
SELECT * FROM `pojos` WHERE (ld.language  =  'en' )  

 

 

I looked at <iterate>, but I don't think I can emulate a similar behaviour
with it.

 

 

Thank you,

 

Kris.

 

 


RE: sql fragment as parameter

Posted by Kris Barnhoorn <kr...@biassweb.be>.
Yes. In my example this is pojos.language.
 
Kris.
 
-----Oorspronkelijk bericht-----
Van: roberto [mailto:roberto@theaegis.org] 
Verzonden: donderdag 30 december 2004 17:49
Aan: ibatis-user-java@incubator.apache.org
Onderwerp: RE: sql fragment as parameter
 
What is ld.language?  Is that in the 'pojos' table with the dot
notation?
 
Roberto
 
 
-----Original Message-----
From: Kris Barnhoorn [mailto:kris@biassweb.be] 
Sent: Thursday, December 30, 2004 11:54 AM
To: ibatis-user-java@incubator.apache.org
Subject: sql fragment as parameter
 
Hi,
 
First I'd like to thank the developers for this great tool.
 
I'd like to insert an sql fragment as a parameter to an sql select
statement.
what i do is generate some sql in a class which is used as
parameterClass in the xml file
 
the whereCriteriaString constructs the string based criteria selectable
on the webpage. Users can choose the make more than one "filter"
 
filter:  property | value | (AND | OR)
add filter
 
 
So I simply did this:
 
      <select id="getPojos" parameterClass="org.foo.SqlQuery"
            resultClass="org.foo.Pojo">
            SELECT *
            FROM `pojos` 
            WHERE 
            <dynamic>
                  <isNotEmpty property="whereCriteriaString">
                        #whereCriteriaString#
                  </isNotEmpty>
            </dynamic>
      </select>
 
What generates 
218 [main] DEBUG sql.PreparedStatement  - {pstm-100004}
PreparedStatement: SELECT * FROM `pojos` WHERE ? 
218 [main] DEBUG sql.PreparedStatement  - {pstm-100004}
PreparedStatement: Parameters: [(ld.language  =  'en' ) ]
218 [main] DEBUG sql.PreparedStatement  - {pstm-100004} Types:
[java.lang.String]
 
This doesn't work
 
So my question is can iBatis generate this?
 
218 [main] DEBUG sql.PreparedStatement  - {pstm-100004}
PreparedStatement: SELECT * FROM `pojos` WHERE (ld.language  =  'en' )  
 
 
I looked at <iterate>, but I don't think I can emulate a similar
behaviour with it.
 
 
Thank you,
 
Kris.
 
 

RE: sql fragment as parameter

Posted by "Daniel H. F. e Silva" <dh...@yahoo.com>.
Guys,

  Use the $property$ notation. Properties with dashes are binded using PreparedStatement class.
What you want to do is a kind of macro substitution. So, use $whereCriteriaString$.
  For any other problems, read the iBATIS Manual. It is quite good indeed!
  Hope that helped you.

Cheers,
 Daniel Silva.

--- roberto <ro...@theaegis.org> wrote:

> What is ld.language?  Is that in the 'pojos' table with the dot notation?
> 
>  
> 
> Roberto
> 
>  
> 
>  
> 
> -----Original Message-----
> From: Kris Barnhoorn [mailto:kris@biassweb.be] 
> Sent: Thursday, December 30, 2004 11:54 AM
> To: ibatis-user-java@incubator.apache.org
> Subject: sql fragment as parameter
> 
>  
> 
> Hi,
> 
>  
> 
> First I'd like to thank the developers for this great tool.
> 
>  
> 
> I'd like to insert an sql fragment as a parameter to an sql select
> statement.
> 
> what i do is generate some sql in a class which is used as parameterClass in
> the xml file
> 
>  
> 
> the whereCriteriaString constructs the string based criteria selectable on
> the webpage. Users can choose the make more than one "filter"
> 
>  
> 
> filter:  property | value | (AND | OR)
> 
> add filter
> 
>  
> 
>  
> 
> So I simply did this:
> 
>  
> 
>       <select id="getPojos" parameterClass="org.foo.SqlQuery"
> 
>             resultClass="org.foo.Pojo">
> 
>             SELECT *
> 
>             FROM `pojos` 
> 
>             WHERE 
> 
>             <dynamic>
> 
>                   <isNotEmpty property="whereCriteriaString">
> 
>                         #whereCriteriaString#
> 
>                   </isNotEmpty>
> 
>             </dynamic>
> 
>       </select>
> 
>  
> 
> What generates 
> 
> 218 [main] DEBUG sql.PreparedStatement  - {pstm-100004} PreparedStatement:
> SELECT * FROM `pojos` WHERE ? 
> 
> 218 [main] DEBUG sql.PreparedStatement  - {pstm-100004} PreparedStatement:
> Parameters: [(ld.language  =  'en' ) ]
> 
> 218 [main] DEBUG sql.PreparedStatement  - {pstm-100004} Types:
> [java.lang.String]
> 
>  
> 
> This doesn't work
> 
>  
> 
> So my question is can iBatis generate this?
> 
>  
> 
> 218 [main] DEBUG sql.PreparedStatement  - {pstm-100004} PreparedStatement:
> SELECT * FROM `pojos` WHERE (ld.language  =  'en' )  
> 
>  
> 
>  
> 
> I looked at <iterate>, but I don't think I can emulate a similar behaviour
> with it.
> 
>  
> 
>  
> 
> Thank you,
> 
>  
> 
> Kris.
> 
>  
> 
>  
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com