Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找根据输入数字(比如 56)查询匹配的记录。ORACLE DB 中的列类型为 Long。期望所有匹配的记录具有 ex - 156、567、12356..等的数字。是否可以在 GRAILS 中为上述内容编写命名查询?还有其他出路吗?
如果要在命名查询中使用数据库函数,可以使用该sqlRestriction子句。请注意,语法必须与您的表而不是域类匹配,因此请考虑:
sqlRestriction
class MyDomain { Date myField }
您的限制可以是:
def namedQueries = { someQuery { sqlRestriction("to_char(my_field, 'dd/mm/yyyy') = '25/07/2013'") } }