tags:

views:

35

answers:

1

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

+1  A: 

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.

Timo Westkämper
Thanks Timo for answering from the Beach! Living the Dream..... Unfortunately I had already ensured that the default parameterless constructor was empty. There are however other public constructors which are not empty. The class files were generated by Hibernate although for the purposes of this test I was not using them in conjunction with the querydsl hibernate classes. I was merely seeing how to query normal every collections of in memory objects. Thanks for your time.
Conrad Rowlands
conrad-rowlands, Have you been able to find a solution?
Timo Westkämper
+1 For answering while on vacation.
ponzao