gpt4 book ai didi

java - org.hibernate.MappingException : Could not determine type for

转载 作者:行者123 更新时间:2023-12-01 18:52:07 25 4
gpt4 key购买 nike

我想创建一个用属性填充我的假对象的@Formulas,而不是三个。 MySimpleData 是 MyHugeObject 的简单版本,我不想完全加载。

 @Formula("(select myObject.id1 as id1, myObject.id2 as id2, myObject"
+ ".id3 as id3 from my_object myObject where myObject.id = this_id)")
private MySimpleData mySimpleData = new MySimpleData();

org.hibernate.MappingException: Could not determine type for: mypackage.MySimpleData

 public class MySimpleData {

private Long id1;
private String id2;
private String id3;

public MySimpleData(Long id1, String id2, String id3) {
this.id1 = id1;
this.id2 = id2;
this.id3 = id3;
}

public MySimpleData() {
}
}

最佳答案

你可以尝试这样的事情。

@Formula("(select new MySimpleData(myObject.id1, myObject.id2, myObject.id3) from my_object myObject where myObject.id = this_id)")
private MySimpleData mySimpleData;

如果仍然遇到相同的错误,请在 MySimpleData 前面添加完整的类路径。

像这样选择 new full.classPath.MySimpleData(..

关于java - org.hibernate.MappingException : Could not determine type for,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59717287/

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