Skip to content
Advertisement

java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast or BeanUtils.copyProperties not working

am new to JPA and springboot unable to get the api response when am using @Query param(I try achieve the inner join)

Repositoty class:

JavaScript

Service class:

JavaScript

am getting the ” [Ljava.lang.Object; cannot be cast ” exception after that I have changed to as below:

service class

JavaScript

foreach added the Object but for the above code am getting null values BeanUtils.copyProperties is not working

please any one suggest how to fix this.

Advertisement

Answer

Your statement

JavaScript

contains parts from ContentManage and Country in select. But your result is only a List<ContentManage>

To solve this you can create a new Dto class containing all the fields from A and from B you need. This Dto class must have an all-args constructor. Then instead of

JavaScript

you can write:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement