我可以创建一个自定义条件查询吗
Can I create a custom criteria query like
我有一个遗留的 PostgreSql table,其中包含具有多个值的列。我想要 select 行包含我搜索中的任何值。
-- Example query
select * from stuff where ARRAY['Value A', 'Value X'] && regexp_split_to_array(thing, '\|');
我可以从 Grails 2.5.1 GORM 4.x 条件查询生成这种类型的 where 条件吗?
仅供参考:我已经看到 "Grails Postgresql Extensions Plugin" 但我现在无法更改我的列定义。
您可以在条件中使用 sqlRestriction
来添加任意 SQL 条件。 bottom of the node reference for createCriteria()
.
中提到了它
Stuff.withCriteria {
sqlRestriction "ARRAY['Value A', 'Value X'] && regexp_split_to_array(thing, '\|')"
}
我有一个遗留的 PostgreSql table,其中包含具有多个值的列。我想要 select 行包含我搜索中的任何值。
-- Example query
select * from stuff where ARRAY['Value A', 'Value X'] && regexp_split_to_array(thing, '\|');
我可以从 Grails 2.5.1 GORM 4.x 条件查询生成这种类型的 where 条件吗?
仅供参考:我已经看到 "Grails Postgresql Extensions Plugin" 但我现在无法更改我的列定义。
您可以在条件中使用 sqlRestriction
来添加任意 SQL 条件。 bottom of the node reference for createCriteria()
.
Stuff.withCriteria {
sqlRestriction "ARRAY['Value A', 'Value X'] && regexp_split_to_array(thing, '\|')"
}