• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with JPQL: distinct

 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am writing simple JPQL. It seems to be not working. It's as

select new com.Names(distinct(cdtwk.cName)) from CSummaryByDateWeek cdtwk;


It says unexpected token: distinct.

When I take out the word distinct, it works fine.I know JPQL have distict keyword word, but then why not working??
 
Rahul Ba
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

It worked as

select distinct new com.Names(cdtwk.cName) from CSummaryByDateWeek cdtwk;

Regards,
Rahul
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, I do the same thing like you , but i don't understand how jpa know that which field need to distinct ?
My jpql is

select DISTINCT new model.Loggoldtmp( DATE_FORMAT(createdate, '%Y-%m-%d') as datevalue,year(createdate) as yearvalue,month(createdate) as monthvalue,quarter(createdate) as seasonvalue,dayofyear(createdate) as dayofyearvalue,dayofmonth(createdate) as dayofmonthvalue,dayofweek(createdate) as dayofweekvalue ,now() as createdate) "+
"from Loggold o";
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic