Open Mobe91 opened 6 years ago
I ran into this issue , expecting an ArrayList<MyResult>
instead of getting an ArrayList<Object[n]>
while doing a union()
.
See: https://stackoverflow.com/questions/74042943/blaze-persistence-how-to-get-real-objects-from-getresultlist
Proposed workaround, wrapping the union()
in a with()
, does work:
CriteriaBuilder<MyResult> cb = cbf.create(entityManager, MyResult.class)
.with(MyResultCTE.class, false)
.bind(..).select(..)
.bind(..).select(..)
...
.from(AClass.class)
.union()
.bind(..).select(..)
.bind(..).select(..)
...
.from(BClass.class)
.endSet()
.end()
.selectNew(MyResult.class)
.with(..)
.with(..)
...
.end()
.from(MyResultCTE.class);
return cb.getQuery.getResultList();
Currently we prevent the use of selectNew in set operations although it actually is a valid use case. There are different strategies to do this: