欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

GRAILS中Criteria的OR的写法 grailsjavasql 

程序员文章站 2024-03-19 23:41:10
...

 

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