使用 querydsl 查询集合时出现 ExceptionInInitializerError
执行以下代码时,在执行查询/投影时出现异常。有人知道我做错了什么吗?非常感谢所有帮助。
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保 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.