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 wang lei <wl...@yahoo.com.cn> on 2006/02/12 06:25:07 UTC

dynamic Sql and two-level parameter

What i mean is just the Sql implements can parse the parameter twice.
   
  Just the following sql.
   
  Select  USER_ID, USER_NAME, PHOTO, USER_MEMO from  DEMO.USER_T    Where USER_NAME>#userName#  AND $condition$
   
  I pass a parameter map which contains "userName---Test" and "condition--USER_ID>#userId#","userId----10";
   
  i want a sql
  Select  USER_ID, USER_NAME, PHOTO, USER_MEMO from DEMO.USER_T    Where USER_ID>? AND  USER_ID?
   
  But i get the following:
  Select  USER_ID, USER_NAME, PHOTO, USER_MEMO from DEMO.USER_T    Where USER_ID>? AND  USER_ID>#userId# 
   
  Ibatis use DynamicSql and SimpleDynamicSql  to parse the sql and parameters.
  But just parse once,so it just support one-level parameter.
  Now i need two-level parameter
   
  I Must add an additional explantion.
  I use "rule" to do CRUD operation instead of config.
   
  If you want insert a record of "USER" table.
  the default id of "insert statement" will be "insertUser".
   
  So the coder just use ibatis like hibernate or ojb.
  They don't know more about the config.
   
    In fact,I know how to use iBatis dynamic SQL capabilites with the
dynamic tags in <select>.
   
  But i want more flexibility, when we develop a project.
  I have a tool to model the entity and generate ibatis xml and java code.
   
  Some time we need build a complicated query to get data.
  It's not easy to write in the xml, too long,too complicated.
   
  So i just use the same way as ojb and hibernate to handle the query problem.
   
  I don't want to use template to build query.
  Just the developers to build the query with java code.
   
  Does anybody has good ideas about it.
  May be i need to extend some classes of the IBatis to implement it.
   
   
   


		
---------------------------------
无限容量雅虎相册,原图等大下载,超快速度,赶快抢注!