gpt4 book ai didi

hibernate - Grails isAttached()和attach()

转载 作者:行者123 更新时间:2023-12-02 14:57:58 27 4
gpt4 key购买 nike

尝试使用

if(!musician.style.isAttached()){
musician.style.attach();
}

isAttached的代码寄存器返回false。
但是,当它尝试attach()时,给我一个错误提示
"object with the same identifier value was already associated with the  session"

帮我明白如果标识符已经与 session 相关联,为什么对isAttached() session 不返回TRUE?

最佳答案

我也遇到了这个问题,即理论在运行时未按预期提供。我的解决方案类似于musician.style = Style.get(styleId),在这里您可以从styleId或在某个地方记得的地方获取params。这当然可以正常工作,但是它是数据库/高速缓存调用,如果在循环内则很糟糕。

关于hibernate - Grails isAttached()和attach(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36391689/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com