我正在尝试从数据库中获取一个查找值,并且我想列出一个单列值的列表,即" value“列。
private Static Final String Custom = "Custom" //lie in class Constants
LookUp.createCriteria.list() {
eq('type',LookupTypeEnum.valueOf(Constants.Custom).toString())
}这个清单类似于select,
如何将此查询转换为
Select Value from LookUp where Type = 'Custom' 我希望我的grails查询返回一个像sql一样的查询结果。我想把它绑定到列表框?
发布于 2013-06-24 14:20:06
我的坏这做了所有的技巧,私有静态最终字符串自定义=“自定义”//位于类常量//LookupTypeEnum是枚举集合实现类如果没有它,您可以简单地将其替换为您的值=“自定义”或变量Constants.Custom
LookUp.createCriteria.list() {
eq('type',LookupTypeEnum.valueOf(Constants.Custom).toString())
projections { //projection does the trick
property('value')
}}
等价的SQl select查询是:
select value from lookup where type='custom' ;https://stackoverflow.com/questions/17023818
复制相似问题