grails - Grails:如何将 @BindUsing 用于带有 belongsTo 的属性
问题描述
我有一个域对象,其结构如下 -
`
class TaxPlan {
String taxCode
String description
Double taxRate
Timestamp dateCreated
Timestamp lastUpdated
static belongsTo = [location: Location]
}
我想改进“位置”属性以使用 bindUsing 注释。我怎么做?我想要下面的代码 -
class TaxPlan {
String taxCode
String description
Double taxRate
Timestamp dateCreated
Timestamp lastUpdated
@BindUsing({
obj, source ->
Location.findByStoreNumber(source['location'])?:RequestContextHolder.currentRequestAttributes()?.session.location
})
static belongsTo = [location: Location]
}
解决方案
推荐阅读
- python - 我可以在常见的 aws Elastic Beanstalk 服务器中同时部署 Flask 和 Django 应用程序吗?
- css - 如何使输出单元格的滚动条在 Safari 上可见?
- apache - modsecurity 防止 Codeigniter 保存谷歌地图位置 url
- css - 如何将标签 ID 向下移动几个空格
- javascript - React dates-Datepicker 不会在 ag-grid react 中过滤
- angularjs - Fullcalendar v.4.2.0 按年按季度显示
- terraform - Terraform:列表到字符串
- mongodb - 确保对 mongoose 模式的嵌套引用具有唯一索引
- c# - 如何用 C# 编写这个 c++ 片段
- influxdb - InfuxDB 中警报的相对/动态回溯时间