ibatis sqlmaping的问题

06-07-27 sqlmap
要生成的SQL语句

select a.doc_id,a.title,a.keyword,a.uploadpath,a.creator,a.create_date,a.uploadimage,a.doc_type,b.dimension_id,b.menu_id

from document a,document_dimension b where a.doc_id=b.doc_id

and ((b.dimension_id='1004' and b.menu_id='1040')or (b.dimension_id='1005' and b.menu_id='1041'))

现在dimension_id,menu_id的值都放在List中。

但不知在sqlmapping里如何配置。

后改为

select

a.doc_id,a.title,a.keyword,a.uploadpath,a.creator,a.create_date,a.uploadimage,a.doc_type

from document a,document_dimension b where a.doc_id=b.doc_id

and ((b.dimension_id='1004' or b.dimension_id='1005')

and (b.menu_id='1040'or b.menu_id='1041'))

<iterate property="dimensionList" open="(" close=")" conjunction="or">

b.dimension_id = #dimensionList[]#

</iterate>

<iterate property="menuList" open="(" close=")" conjunction="or">

b.menu_id = #menuList[]#

</iterate>

这样的配置结果不太对。同时可能menu_id为空,我要判断menu_id为空的话就不会生成b.menu_id="".有没有方法处理。

sqlmap
2006-07-27 00:17
要生成的SQL语句
 select   a.doc_id,a.title,a.keyword,a.uploadpath,a.creator,a.create_date,a.uploadimage,a.doc_type,b.dimension_id,b.menu_id
    from document a,document_dimension b where a.doc_id=b.doc_id 
    and ((b.dimension_id='1004' and b.menu_id='1040')or (b.dimension_id='1005' and b.menu_id='1041'))
现在dimension_id,menu_id的值都放在List中。
但不知在sqlmapping里如何配置。
后改为
 select
    a.doc_id,a.title,a.keyword,a.uploadpath,a.creator,a.create_date,a.uploadimage,a.doc_type
    from document a,document_dimension b where a.doc_id=b.doc_id 
    and ((b.dimension_id='1004' or b.dimension_id='1005')
     and (b.menu_id='1040'or  b.menu_id='1041'))

        <iterate property="dimensionList" open="(" close=")" conjunction="or">
            b.dimension_id = #dimensionList[]#
        </iterate>
        <iterate property="menuList" open="(" close=")" conjunction="or">
          b.menu_id = #menuList[]#
        </iterate>
这样的配置结果不太对。同时可能menu_id为空,我要判断menu_id为空的话就不会生成b.menu_id="".有没有方法处理。

猜你喜欢