GRAILS中Criteria的OR的写法


Java代码   收藏代码
  1. Person.withCriteria {   
  2.     or {   
  3.         and {   
  4.             eq 'lastName''Winter'   
  5.             eq 'firstName''Johnny'   
  6.         }   
  7.         and {   
  8.             eq 'lastName''Brown'   
  9.             eq 'firstName''Jeff'   
  10.         }   
  11.     }   
  12. }   

 

上面的语言将对应如下SQL语句

 

 

 

Sql代码   收藏代码
  1. select   
  2.     this_.id as id0_0_,   
  3.     this_.version as version0_0_,   
  4.     this_.last_name as last3_0_0_,   
  5.     this_.first_name as first4_0_0_   
  6. from   
  7.     person this_   
  8. where   
  9.     (   
  10.         (   
  11.             this_.last_name='Winter'   
  12.             and this_.first_name='Johnny'   
  13.         )   
  14.         or (   
  15.             this_.last_name='Brown'   
  16.             and this_.first_name='Jeff'   
  17.         )   
  18.     )   

你可能感兴趣的:(grails,groovy)