ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anurag Sethi <asethi...@yahoo.com>
Subject RE: Or Criteria with Ibator
Date Wed, 07 Jan 2009 22:19:49 GMT
what you need for your case is as follows:
1)example.Create a criteria1. do crieteria1.andXYX='sss' , and criteria1.andCCCNotIN(list)
2) Create another criteria2. criteria2. andcccIsNull
3)example.or(criteria2)

Tha should do it. 

THen do a example
--- On Wed, 1/7/09, Vinaya Tirikkovalluru <vinaya.tirikkovalluru@converge.com> wrote:
From: Vinaya Tirikkovalluru <vinaya.tirikkovalluru@converge.com>
Subject: RE: Or Criteria with Ibator
To: user-java@ibatis.apache.org
Date: Wednesday, January 7, 2009, 9:51 PM




 
 







Hi Anurag,  

   

Thanks for the quick response. 

How does your sql look? 

   

I am looking for something like  

select * from abc where xyz = ‘sss’
and ccc not in (12,34,56) or ccc is null 

I could also use  this with a NVL like  

select * from abc where xyz = ‘sss’
and nvl(ccc,’!!!’) not in (12,34,56)  

   

I got the NVL() get to work by defining a
method in the example for the criteria 

   

   

Thanks 

Vinaya 

   









From: Anurag Sethi
[mailto:asethi_im@yahoo.com] 

Sent: Wednesday, January 07, 2009
4:44 PM

To: Vinaya Tirikkovalluru

Subject: Re: Or Criteria with
Ibator 



   


 
  
  I used the following combination of ANDs and ORs.
  Hope this helps.

  

  MyExample example = new MyExample();

          Iterator<MyItem> items =
  itemToDispShipOption.keySet().iterator();

          MyExample.Criteria criterion =
  null;

          HashMap<String,MyItem> map =
  new HashMap<String,MyItem>();

          

        while(items.hasNext()){

              MyItem
  item = items.next();

            

              MyOption
  shipOption = itemToDispShipOption.get(item);

              criterion
  = example.createCriteria();

             
  example.or(criterion);

             
  criterion.andSessionIdEqualTo(sessionKey);

             
  if(-1!=partnerId)

                         
  criterion.andPartnerIdEqualTo(partnerId);

             
  criterion.andItemIdEqualTo(item.getItemId());

  

            
  criterion.andSmIdEqualTo(shipOption.getShipMethodID());

          }

         
  example.setOrderByClause("partner_id,sm_id,item_id");

          try{

             
  allSelected = getCachedShippingOptionPriceDAO().selectByExample(example);

          }catch(SQLException sqlE){

            
  logger.log(Level.SEVERE,sqlE.toString());

          }

  

  --- On Wed, 1/7/09, Vinaya Tirikkovalluru <vinaya.tirikkovalluru@converge..com>
  wrote: 
  From: Vinaya
  Tirikkovalluru <vinaya.tirikkovalluru@converge.com>

  Subject: Or Criteria with Ibator

  To: user-java@ibatis.apache.org

  Date: Wednesday, January 7, 2009, 9:32 PM 
  
  
  Hi, 
    
  Did any one use or in the where clause combined with an and
  condition? 
  Any ideas how to use NVL function in Ibator? 
    
  Thanks 
  Vinaya 
  
  
  
  
  
  This electronic message is intended only for the use
  of the individual(s) or entity(ies) named above and may contain information
  which is privileged and/or confidential. If you are not the intended
  recipient, be aware that any disclosure, copying, distribution, dissemination
  or use of the contents of this message is prohibited. If you received this
  message in error, please notify the sender immediately.  
  
  
  
 


   





This electronic message is intended only for the use of the individual(s) or entity(ies) named
above and may contain information which is privileged and/or confidential.  If you are not
the intended recipient, be aware that any disclosure, copying, distribution, dissemination
or use of the contents of this message is prohibited.  If you received this message in error,
please notify the sender immediately.

 




      
Mime
View raw message