级联“向上”有意义吗?属于属于关系的所有者?
- 我有一个技能类,其中有很多角色技能。
- 我有一个 RoleSkills 类,它属于角色和技能
- 我有一个 Role 类,它有许多 RoleSkills
对于角色,我有一个将操作级联到 RoleSkills 的映射。问题是,RoleSkills“级联”回Skill有意义吗?
我基本上想让 RoleSkill 在创建时创建一项新技能,但如果 RoleSkill 被删除,请保留 Skill 类(它们基本上是相同的,但一旦一个人创建了 RoleSkill,我希望该技能可供其他人使用)使用)。
在grails中,每当我创建一个新角色并为其分配一个RoleSkill时,我都会收到一条有关RoleSkill.skill为空的消息,因此我需要找到一种方法来级联“向上”以在创建新RoleSkill时创建新技能。
- I have a Skill class, which hasMany RoleSkills.
- I have a RoleSkills class which belongsTo Role and Skill
- I have a Role class which hasMany RoleSkills
For Role, I have a mapping that cascades operations to RoleSkills. The question is, does it make sense for RoleSkills to "cascade" back to Skill?
I basically want to have a RoleSkill create a new skill when it is created, but if RoleSkill gets deleted, leave the Skill class (they are basically the same, but once one person makes a RoleSkill I want that Skill the be available for other people to use).
In grails, whenever I make a new Role, and assign it a RoleSkill I am getting a message about RoleSkill.skill being null, so I need to find a way to cascade "up" to create a new Skill whenever a new RoleSkill is made.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要向 RoleSkill 构造函数添加一些逻辑。我不确定这在实践中如何运作,但理论上您可以尝试类似的操作:
请仔细检查 参考文档,同时尝试此实现。希望它能为您指明正确的方向。
I think you would need to add some logic to the RoleSkill constructor. I'm uncertain of how this will work in practice, but in theory you could try something like:
Please double check the reference documentation while trying this implementation. Hopefully it points you in the right direction.