GRAILS中Criteria的OR的写法

阅读更多

 

Person.withCriteria { 
    or { 
        and { 
            eq 'lastName', 'Winter' 
            eq 'firstName', 'Johnny' 
        } 
        and { 
            eq 'lastName', 'Brown' 
            eq 'firstName', 'Jeff' 
        } 
    } 
} 

 

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

 

 

 

    select 
        this_.id as id0_0_, 
        this_.version as version0_0_, 
        this_.last_name as last3_0_0_, 
        this_.first_name as first4_0_0_ 
    from 
        person this_ 
    where 
        ( 
            ( 
                this_.last_name='Winter' 
                and this_.first_name='Johnny' 
            ) 
            or ( 
                this_.last_name='Brown' 
                and this_.first_name='Jeff' 
            ) 
        ) 

 

 

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