java ee - join statement using JPQL (using hibernate jpa) to store in a list -


I Jiraissue table is a table worklog whatever onetomany join to ManyToOne many other tables.

Based on my needs, I wrote a jqpl statement given below.

  @NamedQueries ({@NamedQuery (name = "Worklog.findbySelection", query = "select different workl.jiraissueWorklog.pkey, workl.jiraissueWorklog.summary, workl.jiraissueWorklog.issuestatusOBJ. pname, workl.jiraissueWorklog.cwduserOBJ.displayName, workl.jiraissueWorklog.created, workl.jiraissueWorklog.updated Worklog where workl workl.jiraissueWorklog.project =: workl.startdate the project: STARTDATE and: ENDDATE "),}) < / code>  

now I want to store the output in a list object, so I gave as Worklog object

  @SuppressWarnings ( "unchecked") public list . & Lt; JiraissueColumns & gt; findByDateProject (date STARTDATE, date ENDDATE, long projectID) {query = em.createNamedQuery ( "Worklog.findbySelection"); Query.setParameter ("startDate", startDate); Query.setParameter ("expiration", expiration date); Query.setParameter ("Project", Project ID); This.listOfWorklog = (list & lt; JiraissueColumns & gt;) query.getResultList (); Return listoffarklag; }   

When I use for a loop, what's in the list, I get the following error.

  caused by: java.lang.ClassCastException: [Ljava.lang.Object; IFWorklog   

I believe that the listofworld can only accept the type of wallet and gerge objects, but the project in Juriceu is the issuer object. Will they get in walcg?

What is the correct way to get the output from the JPQL statement?

You are using a non-normal query class. For the parametrized type of query there is a TypedQuery:

  TypedQuery & lt; JiraissueColumns & gt; Query = em.createNamedQuery ("Worklog.findbySelection", JiraissueColumns.class); Query.setParameter ("startDate", startDate); Query.setParameter ("expiration", expiration date); Query.setParameter ("Project", Project ID); Return listoffark_count = query.getResultList ();   

This list and query.getResultList () .

Comments