Grails,确保地图是唯一的
:D 我有这张地图:
[channel:Provider]
如何确保该地图(我的意思是通道+提供商的配对)变得唯一?有没有一种超级简单的方法可以做到这一点?或者我应该为它创建一个自定义验证器.. T__T 我想我可以向包含两列的表添加一个唯一的约束,但我对 grails 有点陌生,这个 GORM 的东西阻止了我表达我的想法。
:D
I have this map:
[channel:Provider]
How do I make sure that the map (and I mean, the pairing of channel + Provider) become unique? Is there a super easy way to do that? Or should I create a custom validator for it.. T__T I think I can add a unique constraint to the table that contains both columns, but I'm a bit new to grails, this GORM thing is preventing me from acting out my thoughts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所有映射都保证键和值的配对是唯一的,因为不能有重复的键。看来要么我误解了你想要实现的目标,要么你误解了地图的工作原理。
All maps guarantee that that the pairing of key and value is unique, because you can't have duplicate keys. It seems that either I'm misunderstanding what you want to achieve, or you're misunderstanding how maps work.