gpt4 book ai didi

playframework-2.0 - 为什么Ebean无缘无故返回null?

转载 作者:行者123 更新时间:2023-12-03 16:29:41 26 4
gpt4 key购买 nike

使用 Play Framework,我有一个这样的模型:

class MyModel extends Model {
// Some columns

@ManyToOne
public OtherModel other;

public OtherModel getOther() {
return other;
}
}

出于我无法理解的原因,如果我调用 myModel.othermyModel.getOther() ( myModelMyModel 的一个实例),我得到了一个 Null 值,即使它应该返回一个 OtherModel 的实例!

此外,如果我更改 getOther()方法:
public OtherModel getOther() {
console.log (String.valueOf(other));
return other;
}
getOther()返回 OtherModel 的预期实例

为什么我会得到这个,以及如何解决这个奇怪的行为?

最佳答案

我遇到了类似的问题(但我不需要 console.log 语句)。

我所做的只是用私有(private)字段替换公共(public)字段,并使用公共(public) getter 和 setter。我认为这是一个 Playframework 错误,但我找不到我在哪里看到的。

关于playframework-2.0 - 为什么Ebean无缘无故返回null?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13011874/

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