spring - Converting Object to Class object -


In my Spring MVC project I'm using Hibernate, using the criteria API Group I and order by clause I'm implementing Query successfully executed DB and also brings results, but an array of object -

The criteria API

  Criteria criteria = session.createCriteria (DashboardSubindicatorSubmission's code .class, "DashboardSubindicatorSubmission") .setProjection (Projections.projectionList () .add (Projections.sum ( "InputValue"). as ( "InputValue")) Kadd (ProjectionskgroupProperty ( "FkAccademicYearId")) Kadd (estimated .groupProperty ( "fkAssessmentPlanID")) .add (Projections.groupProperty ( "fkSubindicatorID")) .add (Projections.groupProperty ( "InputTitle"))) .addOrder (Order.asc ( "fkAccademicYearId")) .addOrder ( Order .asc ("fkAssessmentPlanID"). Theodor (o Order .asc ("Inputtail")); & Lt; DashboardSubindicatorSubmission & gt; DashboardSubandicatorSubmissionList = (list & lt; dashboard SUBIDCETER support & gt;) criteria.list (); Session.flush (); Transaction.commit (); Return dashboardSubandicatorSubmissionist;   

I'm casting from list to criteria.list () & lt; DashboardSubindicatorSubmission & gt; but when I try to dashboardSubindicatorSubmissionList.get (I) This gives me an exception controller java.lang.ClassCastException: [Ljava.lang.Object; Mkcl.accreditation.model.DashboardSubindicatorSubmission can not be molded into

I come to know that, though im listing & lt casting it ;. DashboardSubindicatorSubmission & gt; [ is still a list of your object] thats why can not i DashboardSubindicatorSubmissionListkget (I) do, because for me DashboardSubindicatorSubmission Returns the object of . (I'm right if I am wrong)

How can I change my result to the Dashboard SUBIDCitersSubmission class list? ResultTransformer () Does this help me in this case?

You have two options when you use the estimates, then be respected in every field in hibernation Do not know how to do this because it uses the name of each area to construct objects and it does not yet know the name.

In this way, group your first option field so that they match the name of the object properties. It is necessary, even if the string used in the projection is already the name of the object field. Such as: .add (Projections.groupProperty ("fkAssessmentPlanID"), "Other") / etc. (Projections. GroupProperty ("fkAccademicYearId"), "fkAccademicYearId" The other option is to suggest that you do yourself self-implementation of ResultTransformer. I consider it an interesting option if you want to remove other objects in this query. As you do a report.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -