Multi selection and distinct in a criteria query

#1

hi,

How can I realize multi selection with the criteria api concerning distinct?

I.e. doing something like SELECT DISTINCT $1, $2 wouldn't work because I do only have something like criteria.multiselect(...) and nothing like builder.distinct(selection) so that I could do something like criteria.multiselect(builder.distinct($1), $2)... ??

Alex

#2

distinct is a method of CriteriaQuery.

There are some relevant examples in the manual.

 

ObjectDB Support
#3

Ok yes I am aware of that sorry ;) What I was trying to say.. how can I restrict the DISTINCT to the first selection element in my tuple selection only? I.e. I don't want to every selection expression being distinct (i.e. when selecting names which may double without troubles)

 

Alex

#4

I am afraid it is not supported neither in JPQL nor in criteria queries.

But does it make sense?

Results with identical 2nd element will not be filtered anyway if the first element is different. Only results in which all the elements are identical are filtered.

 

ObjectDB Support
#5

aaahh.. okay that explains it. Well then it should work nevertheless I hope.. :)

Reply