使用 querydsl 查询集合时出现 ExceptionInInitializerError

发布于 2024-09-06 20:39:06 字数 814 浏览 8 评论 0原文

执行以下代码时,在执行查询/投影时出现异常。有人知道我做错了什么吗?非常感谢所有帮助。

Data lt = alias(Data.class,"Data");

for(String location: from ($(lt),Arrays.asList(allData.toArray())).list($(lt.getData()))){
    System.out.println(location);
}

我得到的异常如下:

线程“main”中出现异常 java.lang.ExceptionInInitializerError 在 com.mysema.query.collections.MiniApi.(MiniApi.java:22)... 等

引起:java.lang.NullPointerException 在 com.mysema.codegen.EvaluatorFactory。(EvaluatorFactory.java:51) 在 com.mysema.query.collections.ExprEvaluatorFactory。(ExprEvaluatorFactory.java:55) 在 com.mysema.query.collections.ExprEvaluatorFactory。(ExprEvaluatorFactory.java:50) 在 com.mysema.query.collections.ExprEvaluatorFactory。(ExprEvaluatorFactory.java:32) ... 4 更多

When executing the following code I get an exception when executing the query/projection. Does anybody know what I am doing incorrectly? All help greatly appreciated.

Data lt = alias(Data.class,"Data");

for(String location: from ($(lt),Arrays.asList(allData.toArray())).list($(lt.getData()))){
    System.out.println(location);
}

The Exception I get is as follows:

Exception in thread "main" java.lang.ExceptionInInitializerError
at com.mysema.query.collections.MiniApi.(MiniApi.java:22)... etc.

Caused by: java.lang.NullPointerException
at com.mysema.codegen.EvaluatorFactory.(EvaluatorFactory.java:51)
at com.mysema.query.collections.ExprEvaluatorFactory.(ExprEvaluatorFactory.java:55)
at com.mysema.query.collections.ExprEvaluatorFactory.(ExprEvaluatorFactory.java:50)
at com.mysema.query.collections.ExprEvaluatorFactory.(ExprEvaluatorFactory.java:32)
... 4 more

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放手` 2024-09-13 20:39:06

确保 Data 类有一个空的构造函数。我目前正在度假,没有进一步调查堆栈跟踪的来源,但添加空构造函数将是我要尝试的第一件事。

Querydsl 的别名功能生成动态子类,对于没有空的非私有构造函数的类来说,这会失败。

Make sure that the Data class has an empty constructor. I am currently on vacation and don't have the sources to investigate the stacktrace further, but adding the empty constructor would be my first thing to try.

The alias feature of Querydsl generates dynamic subclasses, and this fails for classes without an empty non-private constructor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文