0

Hi,my HQL query is like this.

 @Query("select A.TheaterName as theater,A.MovieName as movie,CAST(A.ShowDateTime as showDate)" +
         "(select sum(TicketPrice) from ccmsfdb2.HallApi.TicketTransaction where \n" +
         "CAST(ShowDateTime as date)=CAST(A.ShowDateTime as Date) AND\n" +
         " MovieName=A.MovieName and TheaterName=A.TheaterName and TicketStatusValue=1) as collection\n" +
         "from CCMSFDB2.HallApi.TicketTransaction A where A.MovieName='Sanju'  \n" +
         "and A.TheaterName='QFX Jai Nepal' \n" +
         "group by CAST(A.ShowDateTime as date),A.TheaterName,A.MovieName,CAST(A.ShowDateTime as Date)   order by showDate DESC")
    List<MovieCollectionAccordingToTheaaterDto> getMovieCollectionAccordingToTheater();\

In the above query ,I have tried to cast showdatetime as date and sum the gross collection according to date but cast is not supported in hql and i don't want to use native query.

Bakar
  • 383
  • 1
  • 9
  • 27
  • I don't think casting is possible without native query, native query solution https://stackoverflow.com/a/61997704/4207306 – Eklavya May 27 '20 at 05:04

1 Answers1

0

CAST is supported in HQL, given that the underlying DB supports it.

Try full-qualified class name for Date(java.util.Date) inside the @Query expression.

See :
1. HQL Expressions

Bakar
  • 383
  • 1
  • 9
  • 27